I’ve been digging into Shopify App Bridge and am finally feeling pretty familiar with it at this point. I’m working through a very simple embedded POS app that just opens a modal from a cart action, shows a couple of buttons and takes a couple of actions when you click those buttons. Basically the options are to clear the cart, add a customer, remove a customer, add a discount and remove a discount. Nothing fancy by any means. After digging in I’m feeling good about my understanding of what’s happening behind the scenes here. Unfortunately, I’m seeing an anomaly that I was hoping to get another set of eyes on. Let me see if I can explain this clearly…
In my code I’ve subscribed to Cart.Action.UPDATE and, when the cart is updated, I’m just alerting a message to the screen. When I click one of the buttons I mentioned, I fire a call to an App Bridge action. For example, when the “Clear Cart” button is clicked, I call cart.dispatch(Cart.Action.CLEAR). When that runs, I see the cart clear and I am presented with my alert. The same thing happens when I make calls to:
-
cart.dispatch(Cart.Action.SET_CUSTOMER, { data: { id: xxx } }) A customer is successfully added to the cart and I receive the callback from my subscription to the cart update action
-
cart.dispatch(Cart.Action.REMOVE_CUSTOMER) - The customer is successfully removed from the cart and I receive the callback from my subscription to the cart update action
-
cart.dispatch(Cart.Action.REMOVE_DISCOUNT) - Any cart discounts are removed and I receive the callback from my subscription to the cart update action
The ONLY time (at least that I’ve found so far) that I don’t receiving a callback from the cart update action is when I call cart.dispatch(Cart.Action.SET_DISCOUNT, { data: discountPayload }). When I make that call, I do see my discount get added to the cart (so I know there’s nothing wrong with the call itself) but, if I’m not mistaken, it seems almost as if that specific action isn’t correctly firing a cart update action. My verbiage is probably a bit off here but hopefully it makes sense. I’m happy to share my code but before I did that I thought I’d check and see if someone from Shopify would be willing to put eyes on this and see if they can replicate the issue. I’m not 100% sure of the simplest way to replicate what I’m doing but I’d be happy to share whatever I can.
Any help would certainly be appreciated. Thanks!