I’ve had some cart validation functions in my public app successfully running for some time, with no recent changes made.
Today it was noticed that when there are function errors, the response from cart JSON API, is like so:
{status: 422, message: "Cart Error", description: "You can't remove this item from the cart"}
My code has always looked at the message
property for the actual error message, which can then be acted on or displayed on the front-end, not the description
property.
It seems like the behaviour here has changed, unexpectedly.
This is backed up, because even Dawn theme would show the descriptive error message previously when there were failed updates on the Cart. Now it just shows “Cart Error” - i.e. the message
property. Handling of this is built into the theme, not my code.
In fact, the response from /cart/changes, when updating the quantity in the cart is only this…
{errors: "Cart Error"}
… which is clearly not the error message being provided by the cart-validation function.
My function is returning the message using the localizedMessage
prop, like so:
{
localizedMessage: "You can't remove this item from the cart",
target: `$.cart.lines[?(@.id=='${line.id}')]`,
}
I don’t see any other way to do it or any different props I should be using for the descriptive error message.
I can easily update the handling of the response in my app block, but this won’t help with /cart/change errors. In most themes, customers will only see a basic "Cart Error"
displayed for every function error.
Anyone else noticed a change in the behaviour here?
Thanks!