Tags/topics: 
1
Answers
Vote up!
2
Vote down!

How to add the same product to cart more than one time

Hello ,

So , i have created a line item field called field_option which is usually size or color that i obtain from on SAP endpoint via soap , and i set programaclly when i add to cart and it works fine ,

        global $user;
        $product = commerce_product_load($product_id);
        $product_wrapper = entity_metadata_wrapper('commerce_product', $product);
        $line_item = commerce_product_line_item_new($product, $quantity);
        $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
        <strong>$line_item_wrapper->field_option = $option;</strong>
        $line_item_wrapper->save();
        commerce_cart_product_add($user->uid, $line_item)

But when i add the same product with a diferent field_option value , it only adds the quantity to the existing line item , it doesn't create a new one as at least i expected . Can anyone help ?

Thanks a lot ,

Paulo

Asked by: Paulo Maia
on March 3, 2016

1 Answer

Vote up!
0
Vote down!

Set FALSE at combine params :
commerce_cart_product_add($user->uid, $line_item , FALSE)

Answer by: Paulo Maia
Posted: Mar 8, 2016