Price "From" doesn't include tier prices

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
From the category page

e.g. http://www.inkredible.co.uk/c/414/canon-pgi-525-cli-526-and-compatibles

The "From" prices doesn't look at the lowest tier price for the customer role which gives the customer inaccurate information.

Darren
12 years ago
Thanks for reporting. I'll be fixed in the near time
12 years ago
Fixed. Please see changeset e182acd5f448
12 years ago
a.m. wrote:
Fixed. Please see changeset e182acd5f448


Hi,

This still doesn't work for me

See this URL

http://www.inkredible.co.uk/c/629/sx200-ink-cartridges

Shows "Remanufactured Cartridges for Epson Stylus SX200" From £4.99

Look at the product variants and tiers. You can get black cartridges From £2.50

Darren
12 years ago
Opps, wrong logic. Thanks, I'll fix it in the near time
12 years ago
Fixed. Please see changeset 76304efef58c
12 years ago
a.m. wrote:
Fixed. Please see changeset 76304efef58c


Hi mate,

Sorry but I think we still have a problem.

Consider this page - http://localhost:7725/c/396/?categoryId=categoryplaceholder

It says prices from £2.25. Prices are actually from £2.70

Looks like the "From" price calculation doesn't add on tax (we have VAT set to 20%) even though other prices are shown tax inclusive
12 years ago
wunpac wrote:
I presume it meant http://www.inkredible.co.uk/c/396/sx200-ink-cartridges

Could you please debug what exactly is wrong ('PrepareProductPriceModel' method of 'CategoryController')? How exactly is your product and its variants are configured (maybe screenshots)? Do you have any discounts applied to these product variants?
12 years ago
a.m. wrote:
Consider this page - http://localhost:7725/c/396/?categoryId=categoryplaceholder
I presume it meant http://www.inkredible.co.uk/c/396/sx200-ink-cartridges

Could you please debug what exactly is wrong ('PrepareProductPriceModel' method of 'CategoryController')? How exactly is your product and its variants are configured (maybe screenshots)? Do you have any discounts applied to these product variants?


Hi,

I've found the issue.

line:223 should be:-

model.Price = String.Format(_localizationService.GetResource("Products.PriceRangeFrom"), _priceFormatter.FormatPrice(finalPrice));


finalPrice needs passing instead of minimalPrice.Value

There also needs to be a conditional statement that looks to see if there are more than 1 product variant (not just tier prices)

  if (product.ProductVariants.Count > 0)
                                        {
                                            model.OldPrice = null;
                                            model.Price = String.Format(_localizationService.GetResource("Products.PriceRangeFrom"), _priceFormatter.FormatPrice(finalPrice));
                                  
                                            }


Let me know if you want me to send you the full script
12 years ago
Here is the full method in any case

  protected ProductModel.ProductPriceModel PrepareProductPriceModel(Product product)
        {
            if (product == null)
                throw new ArgumentNullException("product");

            var model = new ProductModel.ProductPriceModel();
            var productVariants = _productService.GetProductVariantsByProductId(product.Id);

            switch (productVariants.Count)
            {
                case 0:
                    {
                        //no variants
                        model.OldPrice = null;
                        model.Price = null;
                    }
                    break;
                default:
                    {
                        
                        if (_permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                        {
                            //calculate for the maximum quantity (in case if we have tier prices)
                            decimal? minimalPrice = null;
                            var productVariant = _priceCalculationService.GetProductVariantWithMinimalPrice(productVariants, _workContext.CurrentCustomer, true, int.MaxValue, out minimalPrice);

                            if (!productVariant.CustomerEntersPrice)
                            {
                                if (productVariant.CallForPrice)
                                {
                                    model.OldPrice = null;
                                    model.Price = _localizationService.GetResource("Products.CallForPrice");
                                }
                                else if (minimalPrice.HasValue)
                                {
                                    //calculate prices
                                    decimal taxRate = decimal.Zero;
                                    decimal oldPriceBase = _taxService.GetProductPrice(productVariant, productVariant.OldPrice, out taxRate);
                                    decimal finalPriceBase = _taxService.GetProductPrice(productVariant, minimalPrice.Value, out taxRate);

                                    decimal oldPrice = _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, _workContext.WorkingCurrency);
                                    decimal finalPrice = _currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, _workContext.WorkingCurrency);

                                    //do we have tier prices configured?
                                    var tierPrices = productVariant.TierPrices
                                        .OrderBy(tp => tp.Quantity)
                                        .ToList()
                                        .FilterForCustomer(_workContext.CurrentCustomer)
                                        .RemoveDuplicatedQuantities();
                                    if (tierPrices.Count > 0 && !(tierPrices.Count == 1 && tierPrices[0].Quantity <= 1))
                                    {
                                        //When there is just one tier (with  qty 1), there are no actual savings in the list.
                                        model.OldPrice = null;
                                        model.Price = String.Format(_localizationService.GetResource("Products.PriceRangeFrom"), _priceFormatter.FormatPrice(finalPrice));
                                    }
                                    else
                                    {
                                        if (product.ProductVariants.Count > 0)
                                        {
                                            model.OldPrice = null;
                                            model.Price = String.Format(_localizationService.GetResource("Products.PriceRangeFrom"), _priceFormatter.FormatPrice(finalPrice));
                                  
                                            }
                                        else
                                        {
                                        if (finalPriceBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                        {
                                            model.OldPrice = _priceFormatter.FormatPrice(oldPrice);
                                            model.Price = _priceFormatter.FormatPrice(finalPrice);
                                        }
                                        else
                                        {
                                            model.OldPrice = null;
                                            model.Price = _priceFormatter.FormatPrice(finalPrice);
                                        }
                                            }
                                    }
                                }
                                else
                                {
                                    //Actually it's not possible (we presume that minimalPrice always has a value)
                                    //We never should get here
                                    Debug.WriteLine(string.Format("PrepareProductPriceModel with minPrice not set. Variant ID = {0}", productVariant.Id));
                                }
                            }
                        }
                        else
                        {
                            //hide prices
                            model.OldPrice = null;
                            model.Price = null;
                        }
                    }
                    break;
            }

            //'add to cart' button
            switch (productVariants.Count)
            {
                case 0:
                    {
                        // no variants
                        model.DisableBuyButton = true;
                    }
                    break;
                case 1:
                    {

                        //only one variant
                        var productVariant = productVariants[0];
                        model.DisableBuyButton = productVariant.DisableBuyButton || !_permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart);
                        if (!_permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                        {
                            model.DisableBuyButton = true;
                        }
                    }
                    break;
                default:
                    {
                        //multiple variants
                        model.DisableBuyButton = true;
                    }
                    break;
            }
            
            return model;
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.