Jump to content

Product Page Issue


Naldinho

Recommended Posts

This is a repeat of a question I already asked but now I have more info so hopefully, someone can help me.

Every time I change an attribute on the product page it resets the quantity to the minimum quantity.

I've searched and found other people having the issue but no solutions.

I'm >95% certain that this is caused by the way my server is setup -- specifically because I have ngnix serving the static content with apache behind it. I'm not 100% certain but pretty close to 100% certain that this is the cause of my issue.

 

That said I'm not the only one using that kind of server setup so obviously, there is a solution.

If someone has a solution great but at this point I'll even just settle for someone who knows more about how PrestaShop works to explain how the product page right panel works.

 

My guess is that when I change an attribute it is failing to reload the recently set value of quantity so it just sets it to the minimum. 

 

Any insight would be helpful

Link to comment
Share on other sites

I don't think it is a PrestaShop bug -- if it was when version 1.6.1.9 came out it would have been a huge issue so I do think it is environment based -- much like the vast majority of people have no issue with maintenance mode but for the people who have a server setup like mine we either have to manually enter our IP or change a line of code to get the IP otherwise it adds the server's IP to the whitelist and everyone can access the store in maintenance mode.

I feel that something like that is happening here. That when the quantity is changed the value is set in one version but that when the attribute is changed and the box is updated to do a displayed price update PrestaShop references a second copy of the something and in that copy the quantity is not set so it reverts to default. This is the best theory I can come up with and I think I'm close but not knowing how PrestaShop works and not being a web developer makes it difficult to debug. 

I'd be willing to switch to a more traditional Apache only server setup but when I try to do that it breaks the site so the easiest way to do that would be to make a new server and then move the site except I'd also need to move the mail server as well so I rather try to fix this.

Link to comment
Share on other sites

Upgraded to 1.6.1.14 but that did nothing

 

The problem extends beyond just resetting the quantity -- for products that have discounts increasing the quantity by an amount high enough to trigger the discount changes the displayed price to $0. Adding the sale to cart though leads to the correct price being in the cart. The issue is only with how the price is displayed.

The issue is with

<span id="our_price_display" class="price" itemprop="price" content="1.37">CAD $0.00</span>

Somehow the application of a discount changes the value of the displayed text to 0 which would most likely happen in a situation like this by multiplying by 0. 

So my current theory is that discounts are calculated by multiplying the base price by the discount so base price $10 gets multiplied by discount 0.80 for a 20% off discount. If the 0.80 somehow ended up as 0 then I'd have the outcome that is happening. 

The question now is figuring out where and how that happens in PrestaShop. 

Link to comment
Share on other sites

I see issue in quantity table 

<tr class="quantityDiscount_0" data-real-discount-value="CAD $0.00" data-discount-type="percentage" data-discount="8" data-discount-quantity="25">
	<td>
		25
	</td>
	<td>
		8%
	</td>
	<td>Up to CAD $9.92</td>
</tr>

so issue is calculation of data-real-discount-value, will check code in product.tpl and why that is happening and hopefully 

what is solution.

Link to comment
Share on other sites

Try this change:

 

In controllers/ProductController.php on line 337 change from 

        foreach ($quantity_discounts as &$quantity_discount) {
            if ($quantity_discount['id_product_attribute']) {
                $quantity_discount['base_price'] = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, $quantity_discount['id_product_attribute']);

                $combination = new Combination((int)$quantity_discount['id_product_attribute']);
                $attributes = $combination->getAttributesName((int)$this->context->language->id);
                foreach ($attributes as $attribute) {
                    $quantity_discount['attributes'] = $attribute['name'].' - ';
                }
                $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
            } 
            if ((int)$quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
                $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
            }
        }

to

        foreach ($quantity_discounts as &$quantity_discount) {
            if ($quantity_discount['id_product_attribute']) {
                $quantity_discount['base_price'] = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, $quantity_discount['id_product_attribute']);

                $combination = new Combination((int)$quantity_discount['id_product_attribute']);
                $attributes = $combination->getAttributesName((int)$this->context->language->id);
                foreach ($attributes as $attribute) {
                    $quantity_discount['attributes'] = $attribute['name'].' - ';
                }
                $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
            } else {
                $quantity_discount['base_price'] = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC);
            }
            if ((int)$quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
                $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
            }
        }

So I have added one else so base price do get assigned even if special price is defined for all combination so id_product_attribute do get 0 value.

Note this is maybe not complete solution and you could see some issues in cart or order but check it out. 

I will add report to forge and inform you on progress if this bug is not already there.

Link to comment
Share on other sites

Thank you. 

 

That seems to be close but not quite.

The price discounted price displayed now is always the discounted price for the default configuration. For example in the product linked 500 front and back should display a price of $5.21 but it displays as $3.97. $3.97 is the correct discounted price for 500 front only.

That said I know that it is possible to calculate discounted price correctly because when I install a module that displays the discount prices in the box it calculates them correctly for both the default and price modified combinations. 

 

---------------------

 

Even before changing this there was never any issues in cart or orders. When the price displays as $0 if you add to cart it adds the products at the correct price. The problem is isolated to the price display only on the product page. The rest of the time PrestaShop knows the price.
 

---------------------

 

I don't believe this is a necessarily a PrestaShop bug. If it was the forums would be full of people complaining. I think the problem is caused specifically by my hosting environment. 

Edited by Naldinho (see edit history)
Link to comment
Share on other sites

I do not think it is your hosting. I have replicated bug in clean 1.6.1.4 install on our server.

 

Did check few bug reports and there is similar issue and solution but also does not seams to

gives complete solution. check

 

https://github.com/PrestaShop/PrestaShop/pull/7869

 

Have tried code changes proposed and also works for me on product page, but notice comment on that link.

Link to comment
Share on other sites

I tried the code changes and now it calculates the price correctly for the default combination but for any combination where there is a price increase it calculates the price using the base price not the combination price.  For example in the product linked 500 front and back should display a price of $5.21 but it displays as $3.97. $3.97 is the correct discounted price for 500 front only.

 

 

Ok well if this is a bug then it shouldn't be hard to fix. There is a free module from Presto-Chango that calculates the discount price and displays it in the right side box on product page -- I have it enabled now.It is available here  http://www.presto-changeo.com/en/prestashop-free-modules/35-prestashop-quantity-discounts-module.html

Their module calculates the discounted price correctly -- shouldn't it then just be a matter of seeing how they calculated the price and implementing that in ProductController.php?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...