Jump to content

Multiple AJAX add to cart button on the same page


Recommended Posts

Hi all.

As the title say, I would like to know if it's possible to make custom AJAX add to cart button from the one on the product page or from the one in the "homefeatured" module.

When I take the code from the product page and change the ID to the product I want, the problem is that all AJAX add to cart buttons on the page add the same product in the cart (cause the product ID is in a HTML ID).

And when I use the one from "homefeatured", it say that this product is not available anymore (while when I open the link in new tab through the inspector it correctly takes me to the cart page and add the product).

Does anybody have a solution ?

Link to comment
Share on other sites

Find it.

You take the add to cart link from "homefeatured" which looks like :


"<a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')|escape:'html'}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a>"

And you transform it into this with the ID of the product you want this button to add :


"<a class="exclusive ajax_add_to_cart_button" rel="nofollow" data-id-product="{$product.id_product}" href="{$link->getPageLink('cart')|escape:'html'}?qty=1&id_product={$product.id_product}&token={$static_token}&add">{l s='Add to cart'}</a>"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...