/// <summary> /// Adds a <see cref="ProductVariantDisplay"/> to the item cache /// </summary> /// <param name="productVariant"> /// The product variant to be added /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="quantity"> /// The quantity to be represented /// </param> /// <param name="extendedData"> /// The extended Data. /// </param> public void AddItem(ProductVariantDisplay productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if (EnableDataModifiers) { var attempt = _productDataModifier.Value.Modify(productVariant); if (attempt.Success) { var modified = attempt.Result as ProductVariantDisplay; if (modified != null) { extendedData.MergeDataModifierLogs(modified); if (!extendedData.DefinesProductVariant()) { extendedData.AddProductVariantValues(modified); } productVariant = modified; } } } else { extendedData.MergeDataModifierLogs(productVariant); if (!extendedData.DefinesProductVariant()) { extendedData.AddProductVariantValues(productVariant); } } var price = productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(); AddItem(string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, price, extendedData); }
/// <summary> /// Adds a line item to the basket /// </summary> /// <param name="productVariant"> /// The product Variant. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="quantity"> /// The quantity. /// </param> /// <param name="extendedData"> /// The extended Data. /// </param> public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if (!extendedData.DefinesProductVariant()) { extendedData.AddProductVariantValues(productVariant); } var onSale = productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(); AddItem(string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, onSale, extendedData); }
/// <summary> /// Adds a line item to the basket /// </summary> public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if (!extendedData.DefinesProductVariant()) { extendedData.AddProductVariantValues(productVariant); } AddItem( string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(), extendedData); // get the price information from extended data in case it has been overriden //productVariant.SalePrice.Value : productVariant.Price }
/// <summary> /// Adds a line item to the wish list /// </summary> /// <param name="productVariant"> /// The product Variant. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="quantity"> /// The quantity. /// </param> /// <param name="extendedData"> /// The extended Data. /// </param> public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if (!extendedData.DefinesProductVariant()) extendedData.AddProductVariantValues(productVariant); var onSale = productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(); AddItem(string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, onSale, extendedData); }
/// <summary> /// Adds a <see cref="ProductVariantDisplay"/> to the item cache /// </summary> /// <param name="productVariant"> /// The product variant to be added /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="quantity"> /// The quantity to be represented /// </param> /// <param name="extendedData"> /// The extended Data. /// </param> public void AddItem(ProductVariantDisplay productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if (EnableDataModifiers) { var attempt = _productDataModifier.Value.Modify(productVariant); if (attempt.Success) { var modified = attempt.Result as ProductVariantDisplay; if (modified != null) { extendedData.MergeDataModifierLogs(modified); if (!extendedData.DefinesProductVariant()) extendedData.AddProductVariantValues(modified); productVariant = modified; } } } else { extendedData.MergeDataModifierLogs(productVariant); if (!extendedData.DefinesProductVariant()) extendedData.AddProductVariantValues(productVariant); } var price = productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(); AddItem(string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, price, extendedData); }
/// <summary> /// Adds a line item to the basket /// </summary> public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if(!extendedData.DefinesProductVariant()) extendedData.AddProductVariantValues(productVariant); AddItem( string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(), extendedData); // get the price information from extended data in case it has been overriden //productVariant.SalePrice.Value : productVariant.Price }