Jump to content

[Solved] Bug with customized products


Recommended Posts

Hi,

Two weeks ago, I opened a bug report about customized products:
When a customized product is removed from the cart, the quantity of all non-customizable products present in the cart is decreased by 1 (see bug #1549 in the bug tracker for more information).

I wonder why it seems I am the only one having reported this problem.
If this bug is real, every person using this feature must have encountered the issue...

So, if you've already tested features related to customized products, thank you in advance to tell me:
* If you reproduced this bug (and, in that case, you may want to add a comment to my bug report to give your scenario),
* Or if you never observed this behaviour.

Regards.

Link to comment
Share on other sites

Here is a scenario to illustrate issues with customized products (SVN 632):

1. Add to the cart:
* 1 instance of a customized product C1
* 2 instances of another customized product C2
* 1 instance of a non-customizable product N1
* 2 instances of another non-customizable product N2

(see screenshot "bug_custom_001.png")


2. Remove C1 from the cart:
* C1 disappears from the cart: OK
* Both instances of C2 are still present: OK
* The quantity of N1 is decreased by one (quantity of N1 = 0): KO
* The quantity of N2 is decreased by one (quantity of N2 = 1): KO

(see screenshot "bug_custom_002.png")


3. Remove one of both instances of C2 from the cart ("-" button):
* C2 completely disappears from the cart (whereas 1 instance should remain): KO
* The quantity of N1 is now 2147483647: KO
* The quantity of N2 is now 2147483647: KO

(see screenshot "bug_custom_003.png")

6259_G7Ga6xXyXKjuDr9NNXfh_t

6260_aE6nIoSdfgDyOONRGwib_t

6261_28dslAYrXwXIVj1XORUR_t

Link to comment
Share on other sites

Hi kdk,
In fact, yes, I knew about this.
But this behaviour is a strange side effect (but not the only one) of this much more serious bug:
Removing a customized product from the cart also alters the quantity of non-customizable products.
What do you think about it? Quite annoying, isn't it? ;)

More seriously, if you have only the beginning on an idea of a solution to this issue, don't hesitate to share it, it would be greatly appreciated!

Link to comment
Share on other sites

  • 2 weeks later...

Here are the modifications brought to the cart.php file on my Prestashop version (SVN 687):

1/ Look for:

private function _updateCustomizationQuantity($quantity, $id_customization, $id_product, $id_product_attribute, $operator = 'up')


Line 416, replace:

return $this->_deleteCustomization(intval($id_customization));


with:

return $this->_deleteCustomization($id_product,intval($id_customization),$id_product_attribute);



2/ Look for:

public    function deleteProduct($id_product, $id_product_attribute = NULL, $id_customization = NULL)


Line 495, replace:

return $this->_deleteCustomization(intval($id_customization)) AND $this->deleteProduct(intval($id_product), $id_product_attribute, NULL);


with:

$this->_deleteCustomization($id_product,intval($id_customization),$id_product_attribute) AND $this->deleteProduct(intval($id_product), NULL, $id_product_attribute);



3/ Look for:

private    function _deleteCustomization($id_customization)


Lines 515 to 519, replace:

    private    function _deleteCustomization($id_customization)
   {
       if (!$result = Db::getInstance()->getRow('SELECT `quantity` FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.intval($id_customization)) OR 
           !Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'cart_product` SET `quantity` = `quantity` - '.intval($result['quantity'])))
           return false;


with:

  private    function _deleteCustomization($id_product, $id_customization, $id_product_attribute=NULL)
   {
   if (!$result = Db::getInstance()->getRow('SELECT `quantity` FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.intval($id_customization)) OR
       !Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'cart_product` SET `quantity` = `quantity` - '.intval($result['quantity']).' WHERE `id_product`='.intval($id_product).' AND `id_cart` = '.intval($this->id).' AND `id_product_attribute` = '.($id_product_attribute != NULL ? intval($id_product_attribute) : '\'\'')))
           return false;

Link to comment
Share on other sites

  • 2 months later...

Hello there,

First let me thank Major for this fix. It works fine in the cart. However, if you try to delete a customized product from the blockcart (the one in the right column), it doesnt get deleted, only the qty of the product decreases and nothing get changed in the cart.

Could anybody fix this?

Best regards,
Chris

Link to comment
Share on other sites

×
×
  • Create New...