本文整理匯總了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");
}
示例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);
}
}