Bug - Using Tier Price and Product Variant ver 1.20 and 1.30 (Resolved)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
Hello,

When setting up a product and assigning tier pricing and having a product variant with price increase, only the Tier pricing is applied when adding to shopping cart.

Example:
Picture Frame:
Tier pricing - 2 or more $15, 5 or more $10
Product Variant - Size 8 x 10 (0 increase), Size 11 x 14 ($10 increase)

Selections are displayed for the product detail, but add to cart at a qty of 6 and a selection of 11 x 14 and only the price is reduced for qty and product variant increase is not applied.

Any help is appreciated.
14 years ago
Reviewing the PriceHelper.cs I found the following in the "GetUnitPrice" method on about line 273 (version 1.30).

On about line 286 I replaced the Following:
if (productVariant.TierPrices.Count > 0)
                {
                    decimal tierPrice = GetTierPrice(productVariant, shoppingCartItem.Quantity);
                    finalPrice = Math.Min(finalPrice, tierPrice);
                }

With:
if (productVariant.TierPrices.Count > 0)
                {
                    decimal tierPrice = GetTierPrice(productVariant, shoppingCartItem.Quantity);
                    if (tierPrice < productVariant.Price) {
                        finalPrice = (finalPrice - productVariant.Price) + tierPrice;
                    }
                    //finalPrice = Math.Min(finalPrice, tierPrice);
                }

This takes into consideration any change by Tier pricing and previous final price calculations.

Hope this helps anyone with the same scenario.
14 years ago
Do you know of a fix for ver. 1.40?
14 years ago
Hello Joey,

You may just need to search the code for Tierprice and see where it takes you, then walk through the logic to see when and what price is calculated. I haven't looked at 1.4 code yet.

Todd
14 years ago
Ok, I'll see what I can do. Look's some form of Javascript. I'll try to find the code you specified and edit it.
14 years ago
Would this be the right code to change? I have no idea what to change here.

namespace NopSolutions.NopCommerce.Web.Modules
{
    public partial class TierPriceControl : BaseNopUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            ProductVariant productVariant = ProductManager.GetProductVariantByID(this.ProductVariantID);
            
            if (productVariant != null)
            {
                TierPriceCollection tierPrices = productVariant.TierPrices;
                if (tierPrices.Count > 0)
                {
                    lvTierPrices.DataSource = tierPrices;
                    lvTierPrices.DataBind();
                }
                else
                    this.Visible = false;
            }
            else
                this.Visible = false;
        }

        protected void lvTierPrices_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                ListViewDataItem currentItem = (ListViewDataItem)e.Item;
                TierPrice tierPrice = currentItem.DataItem as TierPrice;
                ProductVariant productVariant = tierPrice.ProductVariant;
                
                Label lblQuantity = (Label)currentItem.FindControl("lblQuantity");
                Label lblPrice = (Label)currentItem.FindControl("lblPrice");              

                decimal priceBase = TaxManager.GetPrice(productVariant, tierPrice.Price);
                decimal price = CurrencyManager.ConvertCurrency(priceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                string priceStr = PriceHelper.FormatPrice(price, false, false);
                lblQuantity.Text = string.Format(GetLocaleResourceString("Products.TierPricesQuantityFormat"), tierPrice.Quantity);
                lblPrice.Text = priceStr;
            }
        }
            
        public int ProductVariantID
        {
            get
            {
                object obj2 = this.ViewState["ProductVariantID"];
                if (obj2 != null)
                    return (int)obj2;
                else
                    return 0;
            }
            set
            {
                this.ViewState["ProductVariantID"] = value;
            }
        }
    }
}
14 years ago
Well I can't tell you were to start to change code to get it to work, but Nop 1.4 does the same thing out of the box.
14 years ago
Tier prices are applied only to product variant price (and not applied to product attributes).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.