Zen Cart Logo
Forums / Managing Customers and Orders / code to add products to shopping cart

code to add products to shopping cart

Locked

Views: 2,260

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
28 Aug 2006, 3:52 AM
#1
nutanc avatar

nutanc

New Zenner

Join Date:
Aug 2006
Posts:
4
Plugin Contributions:
0

code to add products to shopping cart

Hi,
I have the following requirement.The user can select a list of items and all the items should get added to the shopping cart at once.For this I am trying out some code.The code I have is as follows```
foreach($idArray as $key => $value) {
echo $idArray[$key]." ";
$_SESSION['cart']->add_cart($idArray[$key]);
}

where idArray is the array of products I have.
The products are getting added,but for some reason the products do not have their prices set and they are all showing 0 as price.
Am I doing something wrong?
28 Aug 2006, 4:49 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: code to add products to shopping cart

If you add those same products to cart from the products page, do they get prices properly?

Are you perhaps trying to add products which have attributes? That will cause problems, because you're not setting attribute data.

Do all the indicated products have a master-categories-id set properly in the database? (usually only a problem if you've linked to many places and then removed links, or imported products and didn't set the master etc)

28 Aug 2006, 10:43 AM
#3
nutanc avatar

nutanc

New Zenner

Join Date:
Aug 2006
Posts:
4
Plugin Contributions:
0

Re: code to add products to shopping cart

Hi Dr.Byte,
Thanks for the prompt reply.I will try to clarify further.
If I add the products from the products page they r getting added properly and the prices are getting updated properly.
Yes,I am adding products which have attributes.In my example they are 'Print Finish' and 'Print Size'. So how do I add attributes to the product in php code?
I think the master-categories-id is not a problem as my products are not linked.
Thanks.
-Chaitanya