首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Commerce Server获取折扣开始日期和结束日期?

问如何从Commerce Server获取折扣开始日期和结束日期?
EN

Stack Overflow用户
提问于 2013-07-09 02:02:24
回答 1查看 300关注 0票数 0

我正在尝试使用Microsoft Commerce Server服务器端代码检索折扣的开始和结束日期。如何才能做到这一点?我唯一被卡住的数据是促销代码"TEST“。关于如何创建折扣对象或CampaignItem对象并设置促销代码以检索其属性,没有太多的代码示例。请帮帮忙。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-24 04:43:47

下面的代码片段演示了如何获取Commerce Server Discount的StartDate和EndDate。这里假设您使用的是Commerce Server 2007 API,并且您知道要从中获取日期的折扣的ID。

代码语言:javascript
复制
//The discount id we want to get dates from.
var discountId = 12;//Set to your ID.

//Configure the Commerce Server site name.
var siteName = "StarterSite";

//We need a MarketingContext instance so we can access the marketing API. 
var mc = MarketingContext.Create(siteName, null, AuthorizationMode.NoAuthorization);

//Get our discount.
var discount = (Discount)mc.CampaignItems.GetCampaignItem(discountId);

//Voila.  Start and End dates.
var startDate = discount.StartDate;
var endDate = discount.EndDate;

注意: API重载返回一个MarketingContext实例,该实例在本地模式下使用营销系统管理MarketingContext.Create。有关这些模式的详细信息,请参阅Understanding the Different Types of Commerce Server APIs。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17533099

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档