Updating Cart Line Item Attributes in an App Block to be used by a Shopify Function

Shopify Partner
3 0 7

I have generated an App Block extension and a Shopify Function inside of the Node JS Shopify App template. I am using the /cart/change.js endpoint to update line item attributes for the cart items inside of the App Block JS file, and I am hoping to use them to apply an automaticAppDiscount for the customer inside of the Shopify function. I have verified the logic inside of the Shopify function works, however I have noticed that the page requires a refresh after a call to /cart/change.js as the PerformanceObserver can only run after the user has clicked add to cart, as such it is updating the line items after they have been added to the basket, so the attributes do not render immediately.

Can someone direct me to the correct way to implement this logic as per Shopify's documentation? I do not see anywhere in which this is explained, and just want to know how Shopify (or others) have gone about doing this!

Replies 0 (0)