Development discussions around Shopify APIs
Hi,
I'm using SriptTag and i can't find an event that can trigger on Item added to cart.
I tried:
Shopify.onItemAdded = function(lineItem) { console.log(lineItem) };
but it does'nt work.
How can i achieve that?
Hey @hassanba,
Not all themes will call Shopify.onItemAdded. If this is for a single store, create a function in your ScriptTag and update the theme to call that function when an item is added to cart. If you're building an app for multiple store, here's one approach to detecting an add to cart.
Scott | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @SBD_ , Thanks for your answer
I tried XHR intercetor on /cart/add.js and it works like a charm
But on checkout button this XHR interceptor does'nt fire !! is there any way to listen on checkout button?
N.B: I'm building an app for multiple store
thanks a lot,
Perhaps also listen for an [action=/checkout] form submit
Scott | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
where are the api docs for these events.
It would be helpful
User | RANK |
---|---|
10 | |
5 | |
3 | |
3 | |
3 |
Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023Summary of EventsBeginning in January of 2023, some merchants reported seeing a large amo...
By Trevor May 15, 2023With 2-Factor Authentication being required to use Shopify Payments, we’re here to help yo...
By Imogen Apr 26, 2023