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.
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