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 |
---|---|
6 | |
5 | |
5 | |
5 | |
4 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022