繁体   English   中英

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

[英]How to get Discount Start and End Date from Commerce Server?

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

以下代码段演示了如何获取Commerce Server DiscountStartDateEndDate 这假定您使用的是Commerce Server 2007 API,并且知道您想要日期的折扣ID。

//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;

注意: MarketingContext.Create重载,返回在本地模式下使用营销系统管理API的MarketingContext实例。 有关这些模式的更多信息,请参见了解不同类型的Commerce Server API

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM