Page 1 of 1

Bug checkbox products

PostPosted: Wed Apr 25, 2018 11:45 am
by inkoop@.....nl
It looks like there is a small bug in the latest version of OPC (in combination with Joomla 3.8.7 and virtuemart 3.14)

I have enabled some checkbox products in the cart check out.

But at the checkout, when enabling a checkbox, a message appeared that removing a item was successful. This message appears when enabling al other checkboxe as well, but doesn’t appear disabling them. The message appears reversed, other way around as how it should be.

I also think displaying this message is not necessary at all, only when removing and real item from the cart, but not for these checkbox products.

Can you fix this?

Re: Bug checkbox products

PostPosted: Thu May 03, 2018 12:58 pm
by admin
hello, this is a bug in virtuemart, you may need to comment 2 lines in cart.php code:

\components\com_virtuemart\helpers\cart.php

original code:
Code: Select all
public function updateProductCart() {

      $quantities = vRequest::getInt('quantity');
      if(empty($quantities)) return false;
      $updated = false;

      foreach($quantities as $key=>$quantity){
         if (isset($this->cartProductsData[$key]) and !empty($quantity) and !isset($_POST['delete_'.$key])) {
            if($quantity!=$this->cartProductsData[$key]['quantity']){
               $this->cartProductsData[$key]['quantity'] = $quantity;
               $updated = true;
               vmInfo('COM_VIRTUEMART_PRODUCT_UPDATED_SUCCESSFULLY');
            }

         } else {
            unset($this->cartProductsData[$key]);
            vmInfo('COM_VIRTUEMART_PRODUCT_REMOVED_SUCCESSFULLY');
            $updated = true;
         }
      }

      $this->setCartIntoSession(true);
      return $updated;
   }


and change it to:

Code: Select all
public function updateProductCart() {

      $quantities = vRequest::getInt('quantity');
      if(empty($quantities)) return false;
      $updated = false;

      foreach($quantities as $key=>$quantity){
         if (isset($this->cartProductsData[$key]) and !empty($quantity) and !isset($_POST['delete_'.$key])) {
            if($quantity!=$this->cartProductsData[$key]['quantity']){
               $this->cartProductsData[$key]['quantity'] = $quantity;
               $updated = true;

            }

         } else {
            unset($this->cartProductsData[$key]);

            $updated = true;
         }
      }

      $this->setCartIntoSession(true);
      return $updated;
   }



it's not acceptable that virtuemart prints those messages from within cart helper file instead of the joomla's controller since the function can be used by any autoreload / load / gift or other plugins manipulating the cart.

we'll be considering not to use this function if the messages don't get removed from the core.

best regards, stan