当前位置: 首页>>代码示例>>C#>>正文


C# Order.AddCouponCode方法代码示例

本文整理汇总了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");
        }
开发者ID:NightOwl888,项目名称:MerchantTribe,代码行数:37,代码来源:PromotionTest.cs

示例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);
            }

        }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:25,代码来源:OrderTest.cs

示例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);
            }

        }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:21,代码来源:OrderTest.cs

示例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");
        }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:14,代码来源:OrderTest.cs

示例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");
 }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:9,代码来源:OrderTest.cs


注:本文中的MerchantTribe.Commerce.Orders.Order.AddCouponCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。