Cart properties not flowing through to completed order in POS app

Highlighted
Shopify Partner
1 0 1

Hi,

 

I'm looking for help troubleshooting an issue with our POS app integration. Our app is integrated into the edit cart menu within Shopify POS and relies on the SDK method "Cart Add Property" to set an order note with information that is later used for processing. Whatever we set as a cart property will come through in the order API as a "note_attribute".

 

A few weeks ago, one of our partners noticed that this stopped working for them. Even though the note was set correctly and visible on the POS order screen, it doesn't stay attached to the actual order once it's submitted. A couple of other nuances:

 

1. I have not been able to reproduce this issue on my developer store and test device, this has only happened to our partner on their live account.

2. This is only a problem on POS classic version. Somehow this is not an issue on the all-new POS version.

 

We have partners that rely on this feature and are not ready to switch to the all-new POS version. Any help here would be greatly appreciated!

 

Thanks

1 Like
Highlighted
Trailblazer
134 12 22

I am also hoping to use this feature and note_attributes is coming back empty in my order creation webhook. I am using App Bridge and iOS with new Shopify POS. 

0 Likes
Highlighted
Trailblazer
134 12 22

Looks like it's a bug where if you set Line Item Properties it shows up in the order-level (Cart) note attribute field. Properties in the actual line item properties remains blank. 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
17 5 3

Hey @Irwin,

Thanks for reaching out about this issue.
I also could not reproduce this issue. I used the latest version of POS in classic mode, POSSDK (not App Bridge directly), and the REST Api (all versions going back to 2019-10).

The `note_attributes` on the order object matched the properties I set with the Add Property function in the SDK.

 

Do you happen to know the POS version the partners that experience this issue are using?

Andrew Apperley
(App Bridge) Mobile Developer
0 Likes
Highlighted
Shopify Staff
Shopify Staff
17 5 3

Hey @policenauts1,

When you set the properties, are you using the line item set property function or the cart set property function? Also, are you using App Bridge or POSSDK?

I'd really like to investigate once I have more information. Thanks

Andrew Apperley
(App Bridge) Mobile Developer
0 Likes
Highlighted
Trailblazer
134 12 22

Hi @andrew-apperley ,

 

Apologies, I'm reading what I wrote and now looking at my source code and must have gotten mixed up. Cart Properties is setting note_attributes correctly at the order level. 

 

For line item properties, I'm using App Bridge and still can't seem to get this to work for iOS and new POS. Does the item already have to be in the cart? I'm calling it immediately after I add the line item to the cart. 

                  cart.dispatch(Cart.Action.ADD_LINE_ITEM, {
                    data: payload
                  });
                cart.dispatch(Cart.Action.SET_LINE_ITEM_PROPERTIES, {
                    index: 0,
                    data: {
                      app: 'myApp',
                    }
                  });         

 

0 Likes
Shopify Staff
Shopify Staff
17 5 3

Hey @policenauts1,

Cart Properties is setting note_attributes correctly at the order level. 

Great to hear!

---

Yes, the item does need to be in the cart. What you have currently would throw and error because dispatches are asynchronous and your code is treating them as synchronous.

The correct way to do this would be to subscribe to the Cart Update action right before adding the line item, then add the property in that callback function, and finally unsubscribe so you don't receive multiple callbacks.

 

var unsubscriber = cart.subscribe(Cart.Action.UPDATE, function (payload) {
    unsubscriber();
    cart.dispatch(Cart.Action.SET_LINE_ITEM_PROPERTIES, {
        index: 0,
        data: {
            app: 'myApp',
        }
    }); 
});
cart.dispatch(Cart.Action.ADD_LINE_ITEM, {
    data: payload
});  

This ensures that the line item has been added to the cart. As an extra measure you could also check if the payload has the line item and if the property has already been added or not.

Andrew Apperley
(App Bridge) Mobile Developer
1 Like
Highlighted
Trailblazer
134 12 22

OK, I got line item properties to work, it seems the item has to already be in the cart. Is there a way to assign line item properties to the item you're adding to the cart? What's the recommended approach here, or do we need to subscribe to cart updates and loop through everything to assign the indices and go from there each time? 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
17 5 3

@policenauts1 Yes. You're right about needing to subscribe to the action. Subscribing is the only way to know an action has been completed.
You can either have a single subscriber and do your logic in there or have multiple subscribers that unsubscribe at some point.

Andrew Apperley
(App Bridge) Mobile Developer
0 Likes
Highlighted
Trailblazer
134 12 22

@andrew-apperley I just edited this, I know why it's not working. I'll send you a private message.

0 Likes