Jump to content

Adding javascript to header


Eutanasio

Recommended Posts

Hi, I've got this instructions but I don't know how to adapt the code to my website:

The add cart button option creates an event that triggers every time a person has clicked the button. This event is called 'doofinder.cart.add'. You need to catch this event and create a function in your code, to call your store's API for the implementation to work. This function will vary from platform to platform. You have to paste the script into your HTML code.

Example of generic implementation:

document.addEventListener('doofinder.cart.add', function(event) {
  const { item_id, amount } = event.detail;
  // add custom code to send the data to your cart API
  console.log("added ${amount} of item #${item_id}");
});

Thanks for the help

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...