CMS MADE SIMPLE FORGE

Cart

 

[#6926] Cart quantity not updating if attributes are used

avatar
Created By: Oliver Seddon (oliverseddon)
Date Submitted: Tue Oct 04 08:35:39 -0400 2011

Assigned To: Robert Campbell (calguy1000)
Version: 1.8.1
CMSMS Version: 1.9.4.3
Severity: Major
Resolution: None
State: Open
Summary:
Cart quantity not updating if attributes are used
Detailed Description:
I have a product with several colour attributes, when I add a quantity of a
certain attribute to the cart it adds it as expected. Although if I go to the
product again and add the same product with the same attribute to the cart it
gets added as a seperate item. This is fine until you check out using the PayPal
gateway as only the first quantity is passed on to PayPal and therfore an
incorrect total is shown.

Is there a way the add to cart button could check and either alert the user to
the fact they already have this item in their cart or simply update the quantity
in the cart if the same item is discovered?



Thanks
Oliver


History

Comments
avatar
Date: 2012-04-01 13:50
Posted By: Igor (Osvencim)

hi! (google translate=))  -- in my case the field is mandatory for all sku
attributes, and I decided in my project this problem somehow:

put code in Cart.module.php after this section            
[code]
if( count($one->get_attributes()) == 0 && count($obj->get_attributes()) == 0 )
	       {
	           // increase the quantity
	           $added = true;
	           $one->set_quantity($one->get_quantity()+$obj->get_quantity());
	           break;
	       }
[/code]

----- my code sample

          // my code sample increase the quanity for attributes


if( (count($one->get_attributes()) == count($obj->get_attributes()) ))
          {
              $curOne = $one->get_attributes();
              $curObj = $obj->get_attributes();

// may be check name, and other need parameters --
              // --  if sku is requered field

              if((int)$curOne[0]->sku === (int)$curObj[0]->sku) 
              {
                $added = true;
                $one->set_quantity($one->get_quantity()+$obj->get_quantity());
                break;
              }
          }