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 | |
4 | |
3 | |
3 | |
3 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023