Jump to content

Cart.php bug undefined variable "real_best_price


Recommended Posts

PS 1.6.0.12

Found this bug today.

 

The customer reported when was requesting checkout and was redirected to login screen.

I don't have more details about how it happened but the customer sent me the errors messages

variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171 Notice: Undefined variable: real_best_price in /var/www/vhosts/website/httpdocs/classes/Cart.php on line 2171

 

 

Only thing i could do is write an override.

I just added this before the line where the error occurs:

if( !isset( $real_best_price ) ){
    $real_best_price = 0;
}

Full override file is attached.

 

Cart.php

Link to comment
Share on other sites

  • 1 month later...

FYI

 

I have the same issue when I'm going on the checkout page (in one page checkout mode) with an empty cart.

I pulled a merge request on PrestaShop github (#2919), it may be fixed on a next version, to avoid the override.

 

My fix is just like yours (line 2171) :

$total_price += isset($real_best_price) && $cart_rule['minimum_amount_tax'] && $cart_rule['minimum_amount_shipping'] ? $real_best_price : 0;
$total_price += isset($real_best_price_wt) && !$cart_rule['minimum_amount_tax'] && $cart_rule['minimum_amount_shipping'] ? $real_best_price_wt : 0;
Link to comment
Share on other sites

×
×
  • Create New...