If we want to display multiple add to cart button for different products then we can use below code on our tpl file. For example, we have a collection page of multiple products with multiple add to cart buttons.
For products without combination –
<form action="{$link->getPageLink('cart')}" method="post"> <input type="hidden" name="token" value="{$static_token}"> <input type="hidden" name="id_product" value="{$product_id}"> <input type="hidden" name="id_customization" value="0"> <input type="hidden" name="qty" value="1"> <button type="submit" data-button-action="add-to-cart" class="btn btn-primary"> <i class="material-icons shopping-cart"></i> {l s='Add to Cart' mod='modulename'} </button> </form>
For products with combination –
<form action="{$link->getPageLink('cart')}" method="post"> <input type="hidden" name="token" value="{$static_token}"> <input type="hidden" name="id_product" value="{$product_id}"> <input type="hidden" name="id_customization" value="0"> {if $matchedCombinationData} {foreach $matchedCombinationData as $matchedCombination} <input type="hidden" data-product-attribute="{$matchedCombination.id_attribute_group}" name="group[{$matchedCombination.id_attribute_group}]" value="{$matchedCombination.id_attribute}"> {/foreach} {/if} <input type="hidden" name="qty" value="1"> <button type="submit" data-button-action="add-to-cart" class="btn btn-primary"> <i class="material-icons shopping-cart"></i> {l s='Add to Cart' mod='modulename'} </button> </form>
Here $matchedCombinationData is an array of combination data of a particular product.
Note : There is no need to add any js file. Prestashop will call by default from their js file.