本文整理汇总了C#中MerchantTribe.Commerce.Orders.Order.AddCouponCode方法的典型用法代码示例。如果您正苦于以下问题:C# Order.AddCouponCode方法的具体用法?C# Order.AddCouponCode怎么用?C# Order.AddCouponCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MerchantTribe.Commerce.Orders.Order
的用法示例。
在下文中一共展示了Order.AddCouponCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanDiscountAnOrderByCoupon
public void CanDiscountAnOrderByCoupon()
{
RequestContext c = new RequestContext();
MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);
app.CurrentStore = new Accounts.Store();
app.CurrentStore.Id = 1;
// Create a Promotion to Test
Promotion p = new Promotion();
p.Mode = PromotionType.Offer;
p.IsEnabled = true;
p.Name = "Discount By Coupon Test";
p.CustomerDescription = "$20.00 off Test Offer!";
p.StartDateUtc = DateTime.Now.AddDays(-1);
p.EndDateUtc = DateTime.Now.AddDays(1);
p.StoreId = 1;
p.Id = 0;
OrderHasCoupon q = new OrderHasCoupon();
q.AddCoupon("COUPON");
p.AddQualification(q);
p.AddAction(new OrderTotalAdjustment(AmountTypes.MonetaryAmount, -20m));
app.MarketingServices.Promotions.Create(p);
// Create a test Order
Order o = new Order();
o.Items.Add(new LineItem() { BasePricePerItem = 59.99m, ProductName = "Sample Product", ProductSku = "ABC123" });
app.CalculateOrderAndSave(o);
Assert.AreEqual(59.99m, o.TotalOrderAfterDiscounts, "Order total should be $59.99 before discounts");
o.AddCouponCode("COUPON");
app.CalculateOrderAndSave(o);
Assert.AreEqual(39.99m, o.TotalOrderAfterDiscounts, "Order total after discounts should be $39.99");
Assert.AreEqual(-20m, o.TotalOrderDiscounts, "Discount should be -20");
Assert.AreEqual(59.99m, o.TotalOrderBeforeDiscounts, "Order total with coupon but before discount should be $59.99");
}
示例2: RemoveCouponCodeTest
public void RemoveCouponCodeTest()
{
Order target = new Order();
RequestContext c = new RequestContext();
c.CurrentStore = new Accounts.Store() { Id = 1 };
OrderRepository repository = OrderRepository.InstantiateForMemory(c);
repository.Create(target);
target.AddCouponCode("one");
target.AddCouponCode("two");
target.AddCouponCode("three");
repository.Update(target);
Assert.IsTrue(target.RemoveCouponCode(target.Coupons[1].Id), "Call to remove failed");
Assert.AreEqual(2, target.Coupons.Count, "Target count should be two!");
Assert.IsTrue(repository.Update(target), "Call to updated failed");
Order actual = repository.FindForCurrentStore(target.bvin);
Assert.AreEqual(2, actual.Coupons.Count, "Coupon count didn't match");
for (int i = 0; i < target.Coupons.Count; i++)
{
Assert.AreEqual(target.Coupons[i].CouponCode, actual.Coupons[i].CouponCode, "Code didn't match for index " + i);
}
}
示例3: CanSaveAndRetrieveCouponsInRepository
public void CanSaveAndRetrieveCouponsInRepository()
{
Order target = new Order();
RequestContext c = new RequestContext();
c.CurrentStore = new Accounts.Store() { Id = 1 };
OrderRepository repository = OrderRepository.InstantiateForMemory(c);
repository.Create(target);
target.AddCouponCode("one");
target.AddCouponCode("two");
target.AddCouponCode("three");
repository.Update(target);
Order actual = repository.FindForCurrentStore(target.bvin);
Assert.AreEqual(target.Coupons.Count, actual.Coupons.Count, "Coupon count didn't match");
for (int i = 0; i < target.Coupons.Count; i++)
{
Assert.AreEqual(target.Coupons[i].CouponCode, actual.Coupons[i].CouponCode, "Code didn't match for index " + i);
}
}
示例4: CanAddCouponAndGetIdNumber
public void CanAddCouponAndGetIdNumber()
{
Order target = new Order();
target.AddCouponCode("one");
target.AddCouponCode("two");
RequestContext c = new RequestContext();
c.CurrentStore = new Accounts.Store() { Id = 1 };
OrderRepository repository = OrderRepository.InstantiateForMemory(c);
repository.Create(target);
Assert.AreEqual(2, target.Coupons.Count, "Coupon count should be one");
Assert.AreNotEqual(0, target.Coupons[0].Id, "Coupon id should never be zero");
Assert.AreNotEqual(target.Coupons[0].Id, target.Coupons[1].Id, "Coupon ids should be unique");
}
示例5: CanAddCouponToOrder
public void CanAddCouponToOrder()
{
Order target = new Order();
Assert.IsTrue(target.AddCouponCode("coupon"), "Add failed");
Assert.IsTrue(target.CouponCodeExists("coupon"), "Validate Check Failed");
Assert.AreEqual(1, target.Coupons.Count, "Coupon count should be one");
Assert.AreEqual("COUPON", target.Coupons[0].CouponCode, "Code didn't match");
}