Add to Cart button by passing product ID in HTML / JavaScript code?

  • Posts: 11
  • Thank you received: 0
8 years 1 week ago #255337

I know how to create an 'Add to Cart' button on an article by simply passing in the product ID, such as '{product 132|pricedis3|pricetax1|cart|quantityfield}'. Since I don't have an option to create a button on article, but I believe we can use custom HTML & Javascript to create a 'Add to Cart' button, would please let me know if there is solution to do that?

If there is no solution, what about via PHP coding in a custom php module? is there a way to do so? Any direction on how to do it will be appreciated.

thank you!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 6 days ago #255358

Hi,

When you edit a product in your HikaShop backend, you can find the "HTML add to cart button" button at the top. If you click on it, you'll get a popup with some HTML you can use to get an add to cart button for that product that you can paste anywhere on your website. It's however less flexible than the content tag system as it doesn't have any options.

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

  • Posts: 11
  • Thank you received: 0
8 years 6 days ago #255426
Attachments:
Last edit: 8 years 6 days ago by Jerome.

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

  • Posts: 11
  • Thank you received: 0
8 years 6 days ago #255427

I don't see "HTML add to cart button", am I in a wrong version of Hikashop? I see 'Add to cat HTML link', here is what I got

<a class="hikashop_html_add_to_cart_link" href="http://127.0.0.3/index.php?option=com_hikashop&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id=1">Add to cart</a>

What I want:
1. A button instead of a link.
2. the Add to cart link overwrite the existing quantity, if I have a quantity of 3 for this item, and after it's 'added' (actually it's updated to), it will become one, I would expect it becomes 4, is it possible?

thank you

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 6 days ago #255458

Hi,

Yes, I meant 'Add to cat HTML link'.
You can do that by changing slightly the code to:

<a class="hikashop_html_add_to_cart_link btn" href="http://127.0.0.3/index.php?option=com_hikashop&ctrl=product&task=updatecart&quantity=1&checkout=1&add=1&product_id=1">Add to cart</a>

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

Time to create page: 0.073 seconds
Powered by Kunena Forum