Zen Cart Logo
Forums / General Questions / shopping cart duplicate product ids

shopping cart duplicate product ids

Locked

Views: 1,084

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
17 Apr 2008, 6:10 AM
#1
restless avatar

restless

New Zenner

Join Date:
May 2006
Posts:
45
Plugin Contributions:
0

shopping cart duplicate product ids

Hi

When adding a product that is already in the cart, how does zencart know when to create a new item in the cart or just increase the quantity?

For example I have an apple in the cart already then I want another apple but I want a green one (different attribute) instead?

So when adding the new apple to the cart instead of increasing the quantity of the first apple to 2, it creates a new cart item so i have 1 green apple and the original apple, so now I have 2 cart items?

Hope that makes sense the reason I ask is because I'm building a custom cart and whenver I use the function

$_SESSION['cart']->actionAddProduct

and add 2 products with the same product_id but different attributes it just creates 1 and increases the quantity.

Thanks heaps!

17 Apr 2008, 10:23 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: shopping cart duplicate product ids

Have a look at /includes/classes/shopping_cart.php and about line 110-140 and this might also be replicated later in the file as to how the attributes are queried

19 Apr 2008, 12:27 AM
#3
restless avatar

restless

New Zenner

Join Date:
May 2006
Posts:
45
Plugin Contributions:
0

Re: shopping cart duplicate product ids

Is this function flawed?

function zen_get_uprid($prid, $params)

Say I am selling a T-Shirt and letting the buyer choose the words to be printed on it, they want 2 of the same product but different attributes (or Options as Zen calls them I think)

because this function generates the same cart key for both T-Shirts it means that it only has the 1 product in the cart with a quanity of 2 but actually it should be 2 products in the cart as they have different attribute values?

It appears zen_get_uprid is ignoring the values, I did a little test

$params = array('23'=>array('75'=>''),'txt_22'=>'my t-shirt text','20'=>'74');
echo zen_get_uprid(180,$params);

echo "\n\n";

$params = array('23'=>array('75'=>''),'txt_22'=>'some other text','20'=>'70');
echo zen_get_uprid(180,$params);

The result:

**180:ba0769eede0e6eb1ec3d3efa59b30a24

180:ba0769eede0e6eb1ec3d3efa59b30a24**

Exactly the same keys, but you can see the attribute values are different, shouldn't this function be generating the key from the values too or am I missing something?

19 Apr 2008, 11:07 AM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: shopping cart duplicate product ids

You can't with default code, order 2 of the same items with different lists of attributes in one order

19 Apr 2008, 12:39 PM
#5
restless avatar

restless

New Zenner

Join Date:
May 2006
Posts:
45
Plugin Contributions:
0

Re: shopping cart duplicate product ids

it's not a different list of attributes, it's the values that are different

So you are saying that you could not have T-shirt product where you let the user enter in text to be printed on it? and have it be 2 different items in the cart?

19 Apr 2008, 4:21 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: shopping cart duplicate product ids

Set this up and try it...

You can have t-shirt - small - fred - one order/add to cart
then t-shirt - small - jane - a seperate order/add to cart

Then one checkout