App reviews, troubleshooting, and recommendations
Hi everyone,
We were able to apply cart discounts to the POS cart through our app up through yesterday. Now, that same function (which is unchanged on our end) just hangs and never completes the promise.
Does anyone else see this?
Here is a snippet of the code (sorry for the loss of indentation):
// Set cart discount function
setCartDiscount = async function (discount, cb=null) {
const r = await shopify.pos.cart.applyCartDiscount(discount);
if (typeof(cb) === 'function') {
cb(r);
} else {
return r;
}
};
// After logic determining if they are eligible, this code is called
Promise.all(
[
setCartDiscount({
title : 'Free Drink Claimed',
type : 'FixedAmount',
amount : 4.50
}),
otherFunctionsOmitted({
// Omitted
})
]
)
.then(() => {
// Omitted
});
Solved! Go to the solution
This is an accepted solution.
In case anyone else runs into this issue, I discovered the underlying problem. Basically, the AppBridge JS library changed (without entry in either the change log nor docs) from taking an object:
await applyCartDiscount({
type : 'FixedAmount',
title : 'Whatever you want it to be',
amount : 5.00
});
to having to pass the parameters in separately:
await applyCartDiscount('FixedAmount', 'Whatever you want it to be', 5.00);
Of course, this is not what the documentation says (https://shopify.dev/docs/api/app-bridge-library/apis/pos#cart-propertydetail-applycartdiscount) , nor what their examples show (https://shopify.dev/docs/api/app-bridge-library/apis/pos#example-cart).
To reiterate, the object-based code worked for a long time. Then, on 4/18/24, it suddenly stopped working. Obviously Shopify made a change and didn't put it in the change log, nor update their docs. Not that I am in any way surprised.
This is an accepted solution.
In case anyone else runs into this issue, I discovered the underlying problem. Basically, the AppBridge JS library changed (without entry in either the change log nor docs) from taking an object:
await applyCartDiscount({
type : 'FixedAmount',
title : 'Whatever you want it to be',
amount : 5.00
});
to having to pass the parameters in separately:
await applyCartDiscount('FixedAmount', 'Whatever you want it to be', 5.00);
Of course, this is not what the documentation says (https://shopify.dev/docs/api/app-bridge-library/apis/pos#cart-propertydetail-applycartdiscount) , nor what their examples show (https://shopify.dev/docs/api/app-bridge-library/apis/pos#example-cart).
To reiterate, the object-based code worked for a long time. Then, on 4/18/24, it suddenly stopped working. Obviously Shopify made a change and didn't put it in the change log, nor update their docs. Not that I am in any way surprised.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024