/// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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
        }
예제 #4
0
파일: Wishlist.cs 프로젝트: arknu/Merchello
        /// <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);
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
파일: Basket.cs 프로젝트: BatJan/Merchello
        /// <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
        }