Jump to content

1.5.5 cart rule error


Recommended Posts

That is the one, but gift voucher will be removed once specific item been deleted..

The second problem is we can apply second coupon like free shipping if gift coupon is already on the shopping cart.

 

It worked on previous version.

 

I'm not sure it's because my updating..

 

Anyone got solution?

Link to comment
Share on other sites

  • 2 weeks later...

There is a bug (PrestaShop 1.5.5.0) in classes/Cart.php in function addCartRule line: 761

 

To fix:

remove code:

if (Db::getInstance()->getValue('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id))
            return false;

 

and replace with:

 

$result = Db::getInstance()->getRow('SELECT id_cart_rule FROM '._DB_PREFIX_.'cart_cart_rule WHERE id_cart = '.(int)$this->id
                          . ' AND id_cart_rule = '.(int)$id_cart_rule);
                if ($result && Db::getInstance()->NumRows()) return false;

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

hi

 

does this function work in ps 1.5.4.1?  Can i replace this with the function from ps 1.5.5.0? the function looks like:

public function addCartRule($id_cart_rule)

    {

        // You can't add a cart rule that does not exist

        $cartRule = new CartRule($id_cart_rule, Context::getContext()->language->id);

        if (!Validate::isLoadedObject($cartRule))

            return false;

        

        // Add the cart rule to the cart

        if (!Db::getInstance()->insert('cart_cart_rule', array(

            'id_cart_rule' => (int)$id_cart_rule,

            'id_cart' => (int)$this->id

        )))

            return false;



        Cache::clean('Cart::getCartRules'.$this->id.'-'.CartRule::FILTER_ACTION_ALL);

        Cache::clean('Cart::getCartRules'.$this->id.'-'.CartRule::FILTER_ACTION_SHIPPING);

        Cache::clean('Cart::getCartRules'.$this->id.'-'.CartRule::FILTER_ACTION_REDUCTION);

        Cache::clean('Cart::getCartRules'.$this->id.'-'.CartRule::FILTER_ACTION_GIFT);

    

        if ((int)$cartRule->gift_product)

            $this->updateQty(1, $cartRule->gift_product, $cartRule->gift_product_attribute, false, 'up', 0, null, false);



        return true;

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

×
×
  • Create New...