Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
85 stars 9 forks source link

POS `ADD_LINE_ITEM` to cart is ignoring line item properties on subsequent calls. #158

Open ckeyes88 opened 1 year ago

ckeyes88 commented 1 year ago

Describe the bug

POS Line item properties are ignored when there's already a line item for the same variant id in the cart

With our current embedded app, we add specific line item properties to line items and then add them to the cart using cart.dispatch(Cart.Action.ADD_LINE_ITEM, payload);. If our app goes to add a second line item to the cart for the same variant but with different properties, the quantity on the original line item is incremented and the properties are ignored.

To Reproduce

Steps to reproduce the behaviour:

Step 1: Add a line item to your cart using the POS SDK

cart.dispatch(Cart.Action.ADD_LINE_ITEM,
  data: {
    price: 25,
    quantity: 2,
    title: "My Item",
    variantId: 272727272,
    properties: [{name: "MyProperty", value: "Custom Property 1"}]
  },
});

Step 2: Add another line item with different properties and the same variant id

cart.dispatch(Cart.Action.ADD_LINE_ITEM,
  data: {
    price: 25,
    quantity: 3,
    title: "My Item",
    variantId: 272727272,
    properties: [{name: "MyOtherPropert", value: "Custom Property 2"}]
  },
});

Expected behaviour

I would expect that the cart would then contain two separate line items with the following attributes, one for each of the calls above and with different line item properties. This is how the storefront behaves and allows us to vary line item properties for the same variant id

What actually happens is that the cart ends up with a single line item with the quantity totaling the sum of both line item calls (x5) and the second line item property is ignored.

Contextual information

It's essentially the same error as in #28 but I thought it would be fixed considering the ADD_LINE_ITEM call now supports passing in properties instead of having to make a subsequent call to SET_LINE_ITEM_PROPERTIES.

Packages and versions

List the relevant packages you’re using, and their versions. For example:

Platform

ckeyes88 commented 1 year ago

@vctrchu #28 has been around a while and this is related. Any chance this will get addressed in the near future?

ckeyes88 commented 1 year ago

cc: @charlesdobson