App reviews, troubleshooting, and recommendations
I am trying to get product info that is added to cart. Shopify.getCart() function returns undefined but opens an alert message saying "there is 1 item in the cart". How to get the cart details using this? any help appreciated
Hey @tsuj. Thanks for this question! I had the exact same one. Did you ever get this sorted out?
I can call the function but it always alerts the value, I just want to set it to a variable!
Turns out it's actually useless unless you do any tweak on the theme. I have used the ajax API for the same functionality. It's pretty flexible.
Shopify.getCart() returns a promise. So, you can use the following to get data:
Shopify.getCart(function (cart){
//here you have the cart object.
console.log(cart);
})
This won't fire up the alert.
Thanks to all who participated in our AMA with 2H Media on planning your 2023 marketing bu...
By Jacqui Mar 30, 2023Thanks 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, 2023