updating the cart

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95149

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.

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
11 years 8 months ago #95169

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.

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95173

cheers

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95182

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: 11 years 8 months ago by Mat.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
11 years 8 months ago #95208

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.

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95399

can you show me an example of the code needed please?

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
11 years 8 months ago #95466

$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.062 seconds
Powered by Kunena Forum