Add-To-Cart Function
The actual method to add items to the cart/checkout workflow varies by platform. This guide will show you where to locate the Klevu Add-To-Cart function if you should need to make adjustments, or write your own functionality.
The Klevu Add-To-Cart button calls the function klevu_addtocart
Example
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.
Enabling the button and/or changing the button text can be done using variables as presented below.
The Klevu Recommendations Add-To-Cart function call contains an extra argument recsKey to identify the specific recommendations banner from where the click originated.
If you are already using Klevu Search via a Klevu App/Extension, you may find that the Add-To-Cart button within the Klevu Templates or Recommendations is already set and operational.
There should be no need to further modify these functions. They are included below for reference.
Configure in KMC : Smart Search → Customizations → Add To Cart
Function location : snippets/klevu-add-to-cart
Note: You can use the provided check for klevu_customAddToCart() ( line 5 above ) for custom cart functionality
Configure in KMC : Smart Search → Customizations → Add To Cart
Function location : templates/components/klevu/klevu-add-to-cart.html
Note: You can use the provided check for klevu_customAddToCart() ( line 4 above ) for custom cart functionality
Configure in KMC : Smart Search → Customizations → Add To Cart
Enable in Magento Admin : Stores → Configuration → Klevu → Search Configuration → Add to Cart Button
Function location : vendor/klevu/module-addtocart/view/frontend/templates/klevu/addtocart/index.phtml
If modifications are required, it is strongly recommended to properly extend the Klevu module to avoid potential conflicts during future updates to the system.
Configure in KMC : Smart Search → Customizations → Add To Cart