本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.AddGiftCardAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.AddGiftCardAttribute方法的具体用法?C# NameValueCollection.AddGiftCardAttribute怎么用?C# NameValueCollection.AddGiftCardAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.AddGiftCardAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToCart
public virtual void AddToCart(List<string> warnings, Product product, NameValueCollection form, ShoppingCartType cartType, decimal customerEnteredPrice,
int quantity, bool addRequiredProducts, int? parentCartItemId = null, ProductBundleItem bundleItem = null)
{
int newCartItemId;
string selectedAttributes = "";
int bundleItemId = (bundleItem == null ? 0 : bundleItem.Id);
var attributes = _productAttributeService.GetProductVariantAttributesByProductId(product.Id);
selectedAttributes = form.CreateSelectedAttributesXml(product.Id, attributes, _productAttributeParser, _localizationService, _downloadService,
_catalogSettings, null, warnings, true, bundleItemId);
if (product.ProductType == ProductType.BundledProduct && selectedAttributes.HasValue())
{
warnings.Add(_localizationService.GetResource("ShoppingCart.Bundle.NoAttributes"));
return;
}
if (product.IsGiftCard)
{
selectedAttributes = form.AddGiftCardAttribute(selectedAttributes, product.Id, _productAttributeParser, bundleItemId);
}
warnings.AddRange(
AddToCart(_workContext.CurrentCustomer, product, cartType, _storeContext.CurrentStore.Id,
selectedAttributes, customerEnteredPrice, quantity, addRequiredProducts, out newCartItemId, parentCartItemId, bundleItem)
);
if (product.ProductType == ProductType.BundledProduct && warnings.Count <= 0 && newCartItemId != 0 && bundleItem == null)
{
foreach (var item in _productService.GetBundleItems(product.Id).Select(x => x.Item))
{
AddToCart(warnings, item.Product, form, cartType, decimal.Zero, item.Quantity, false, newCartItemId, item);
}
if (warnings.Count > 0)
DeleteShoppingCartItem(newCartItemId);
}
}