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
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023