I believe there's a bug in the interaction between the Storefront API's new Cart object and Shopify's Script Editor scripts. The bug is that Line-Item scripts do not execute on Cart related mutations.
I can copy & paste GraphQL queries & responses all day. But the gist of it is, using the latest `v.2021-10` GraphQL endpoint, the published Shopify Script Editor Line-Item scripts properly execute on the `checkoutLineItemsAdd` mutation but does not execute whatsoever on the `cartLinesAdd` mutation. This statement of behavior is true for all the other mutations of those objects.
My Script Editor App's published Line-Item script is fully functional. It is, take my word for it. It's easy to write a simple script to verify this, do it.
I assume Shopify created the new Cart object to lighten the processing and database load related to the heavier Checkout object. There's a lot of customer `line_item` activity that never makes it to checkout so why should we burden the checkout infrastructure unnecessarily, right? So, once a customer gets their Cart items locked-in as desired, they then get promoted to Checkout items (eventually). But what if customers change their mind last minute and still want to change some checkout line_items, right? Well that's why keeping both implementations makes sense. So I get that the CartLine object is not a replacement for the CheckoutLineItem object. As a result, there are two places to edit `line_items` that are or will eventually be Checkout related `line_items`. We all understand.
"A Cart represents the merchandise that a buyer intends to purchase"
And maybe "intends" there means it operates more like a semi-functional Cart; a casual wish-list?
But I still can't really understand why it would make sense to not enact my cart `line_item` modifications executed by the Script Editor on that Cart object. For the customer, this is a very disorienting & misleading experience. Imagine the customer not experiencing the Script Editor `line_item` modifications while browsing the website and using the Cart... and then all of a sudden a rush of `line_item` changes unexpectedly appear when their `line_items` are promoted from Cart to Checkout.
As a result of this current behavior, whether it be a bug or not, I'm forced to continue using the Checkout object site-wide and ignore the new Cart object completely. That means the benefits Shopify intended to realize will not be realized. I don't think this is the intended effect Shopify was moving towards when they conceived of the Cart object concept.
Does this mean one of:
Scripts apply in the Liquid cart in Shopify themes so it makes no sense that in the storefront api they do not.
It would be great that Shopify clarifies this
Have you created a collection on your online store and experienced an issue with adding yo...By Ollie Aug 24, 2022
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...By Ollie Jul 28, 2022