refresh cart

  • Posts: 217
  • Thank you received: 1
12 years 9 months ago #38372

Hi Nic,

I add items to the cart via url.

$.get("<?php echo JURI::root(); ?>index.php?option=com_hikashop&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id=43");		

which works. However the cart doesn't get updated until I refresh the page.

Am I doing something wrong? How can I refresh the cart on the page?

Mat

Last edit: 12 years 9 months ago by Mat.

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

  • Posts: 217
  • Thank you received: 1
12 years 9 months ago #38379

Also with the above code how do I add 1 to cart rather than replace the current quantity with 1?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 9 months ago #38507

That's normal. You're just sending a request to the server telling it to add the product into the cart in the database.
You're not refreshing the cart module with the new cart module which requires more complex javascript. The simplest will be to not use ajax and just have the whole page refresh.
Otherwise, if you really want to do it in ajax and refresh the cart module, you should base your JS code on the JS code near the end of the file administrator/components/com_hikashop/helpers/cart.php

To add instead of replacing, just add the parameter &add=1 in the URL.

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

Time to create page: 0.059 seconds
Powered by Kunena Forum