Skip to main content

updating the cart

More
13 years 6 months ago #95149 by Mat
updating the cart was created by Mat
Hi all,

I use the following url to add a product to the cart:

index.php?option=com_hikashop&ctrl=product&task=updatecart&add=1&quantity=1&product_id=47

now what if I want to add three products to the cart at once - is that possible?

Thanks,

Mat

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #95169 by nicolas
Replied by nicolas on topic updating the cart
Hi,

I think that should URL should work in that case:
index.php?option=com_hikashop&ctrl=product&task=updatecart&add=1&data[47]=1&data[48]=2

47 and 48 are the product ids and 1 and 2 are the quantities.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #95173 by Mat
Replied by Mat on topic updating the cart
cheers

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago - 13 years 6 months ago #95182 by Mat
Replied by Mat on topic updating the cart
and what if each product had custom fields that i wanted to add to each one?

this doesn't seem to work:
data[47]=1&data[47][firstname]=qwerty&data[48]=1&data[item][firstname]=asdfgh
nor this:
data[47]=1&data[item][firstname]=qwerty&data[48]=1&data[item][firstname]=asdfgh

it only adds the data item to the second object.
Last edit: 13 years 6 months ago by Mat.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #95208 by nicolas
Replied by nicolas on topic updating the cart
You can't add several products with different custom field values at the same time via the add to cart URL.
You would have to code that in a PHP script instead.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #95399 by Mat
Replied by Mat on topic updating the cart
can you show me an example of the code needed please?

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #95466 by nicolas
Replied by nicolas on topic updating the cart
Code:
$cartClass = hikashop_get('class.cart'); $cartContent = $cartClass->get(0, true, 'cart'); if(empty($cartContent)) { $cartClass->initCart(); } $cartClass->updateEntry(1, $cartContent, 47, 0, false); $cartClass->updateEntry(2, $cartContent, 48, 0, false);

Please Log in or Create an account to join the conversation.

Time to create page: 0.189 seconds
Powered by Kunena Forum