Add to Cart

If you are already using Klevu Search via our Magento, Shopify or BigCommerce App, you may find that the Add to Cart button within our Klevu Themes or Recommendations already works.

If the add to cart functionality is not working, you may need to take an additional step to implement this feature for your respective platform.

Note: Only complete the following steps if you do not already have a function klevu_addtocart() included in your store. Please check with your frontend developer if you are not sure.

Shopify

The logic for adding an item to the cart in Shopify is quite simple. Add this to any pages of your Shopify store where a Klevu Add to Cart button might appear, ideally in your theme.liquid:

BigCommerce

The logic for adding an item to the cart in BigCommerce is quite simple. Add this to any pages of your BigCommerce store where a Klevu Add to Cart button might appear, ideally in your base.html:

Magento

The URL to add a product to the cart must be generated by Magento, as it contains protection against cross site scripting (XSS), so you will need to implement one JavaScript function within your Magento theme.

You can find our implementation of this logic here:
https://github.com/klevu/addtocart/blob/master/view/frontend/templates/klevu/addtocart/index.phtml

Other Platforms

For any other platforms, simply implement the function klevu_addtocart with your own logic of what you would like to happen when a customer clicks on add to cart: