productFormsFilter
Liquid Ajax Cart ajaxifies all Shopify product forms by default.
But, for example, if you want to ajaxify only product forms with the data-my-product-form
attribute then provide a function as the productFormsFilter
parameter:
<script type="module">
import { configureCart } from '{{ "liquid-ajax-cart-v1.11.2.js" | asset_url }}';
configureCart('productFormsFilter', formNode => {
return formNode.hasAttribute('data-my-product-form')
});
</script>
Liquid Ajax Cart will call your function and pass the Element object of the product form that is going to add a product to the cart, and proceed with an “Add to cart” Ajax request only if the function returns true
.