Add products to the cart programmatically

  • Posts: 5
  • Thank you received: 0
9 years 2 months ago #215406

-- url of the page with the problem -- : www.thankgodi.com
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.5.9
-- Browser(s) name and version -- : Firefox 37.0.2
-- Error-message(debug-mod must be tuned on) -- : No error message

Hi guys,

I'm building a solution for my client, where I provide an interface that allows call center operators to create a cart with products on behalf of the customer (the caller). When the operator hits save, the cart is created (with products), and a mail is sent out to the customer, who when they click it, logs them in automatically, loads up their cart, and takes them straight to checkout.

In theory, this works well. In practice, I can't find out how to programmatically add items to a cart. If I try AJAX calls to something like:

"option=com_hikashop&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id=X"

Then I'm just told by Hikashop that the product is not available (it is...)

What is the best way to add items to a cart without using Hikashop's various interfaces?

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

  • Posts: 82868
  • Thank you received: 13375
  • MODERATOR
9 years 1 month ago #215408

Hi,

An ajax request to that URL is indeed an easy solution you can use. If the system tells you that the product is not available it's probably that it isn't. It could be that it doesn't have stock, that you have some limits configured, or that the product is actually a product with characteristics and that you put the product_id of the main product instead of the product_id of the variant that you want to add, or that you didn't set any price in your product and that you have the Display add to cart button for free products turned off in the hikashop configuration.

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

Time to create page: 0.059 seconds
Powered by Kunena Forum