當前位置: 首頁>>代碼示例>>C#>>正文


C# Customer.ApplyGiftCardCouponCode方法代碼示例

本文整理匯總了C#中Nop.Core.Domain.Customers.Customer.ApplyGiftCardCouponCode方法的典型用法代碼示例。如果您正苦於以下問題:C# Customer.ApplyGiftCardCouponCode方法的具體用法?C# Customer.ApplyGiftCardCouponCode怎麽用?C# Customer.ApplyGiftCardCouponCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nop.Core.Domain.Customers.Customer的用法示例。


在下文中一共展示了Customer.ApplyGiftCardCouponCode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Can_not_add_duplicate_giftCardCouponCodes

        public void Can_not_add_duplicate_giftCardCouponCodes()
        {
            var customer = new Customer();
            customer.ApplyGiftCardCouponCode("code1");
            customer.ApplyGiftCardCouponCode("code2");
            customer.ApplyGiftCardCouponCode("code1");

            var codes = customer.ParseAppliedGiftCardCouponCodes();
            codes.Length.ShouldEqual(2);
            codes[0].ShouldEqual("code1");
            codes[1].ShouldEqual("code2");
        }
開發者ID:nopmcs,項目名稱:mycreativestudio,代碼行數:12,代碼來源:CustomerTests.cs

示例2: MigrateShoppingCart

        /// <summary>
        /// Migrate shopping cart
        /// </summary>
        /// <param name="fromCustomer">From customer</param>
        /// <param name="toCustomer">To customer</param>
        /// <param name="includeCouponCodes">A value indicating whether to coupon codes (discount and gift card) should be also re-applied</param>
        public virtual void MigrateShoppingCart(Customer fromCustomer, Customer toCustomer, bool includeCouponCodes)
        {
            if (fromCustomer == null)
                throw new ArgumentNullException("fromCustomer");
            if (toCustomer == null)
                throw new ArgumentNullException("toCustomer");

            if (fromCustomer.ID == toCustomer.ID)
                return; //the same customer

            //shopping cart items
            var fromCart = fromCustomer.ShoppingCartItems.ToList();
            for (int i = 0; i < fromCart.Count; i++)
            {
                var sci = fromCart[i];
                AddToCart(toCustomer, sci.Product, sci.ShoppingCartType, sci.StoreId, 
                    sci.AttributesXml, sci.CustomerEnteredPrice,
                    sci.RentalStartDateUtc, sci.RentalEndDateUtc, sci.Quantity, false);
            }
            for (int i = 0; i < fromCart.Count; i++)
            {
                var sci = fromCart[i];
                DeleteShoppingCartItem(sci);
            }
            
            //migrate gift card and discount coupon codes
            if (includeCouponCodes)
            {
                //discount
                var discountCouponCode  = fromCustomer.GetAttribute<string>(SystemCustomerAttributeNames.DiscountCouponCode);
                if (!String.IsNullOrEmpty(discountCouponCode))
                    _genericAttributeService.SaveAttribute(toCustomer, SystemCustomerAttributeNames.DiscountCouponCode, discountCouponCode);
                
                //gift card
                foreach (var gcCode in fromCustomer.ParseAppliedGiftCardCouponCodes())
                    toCustomer.ApplyGiftCardCouponCode(gcCode);

                //save customer
                _customerService.UpdateCustomer(toCustomer);
                 
            }
        }
開發者ID:jasonholloway,項目名稱:brigita,代碼行數:48,代碼來源:ShoppingCartService.cs


注:本文中的Nop.Core.Domain.Customers.Customer.ApplyGiftCardCouponCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。