Cart and checkout validation app

I have been using a custom app with cart and checkout extension, where i have written rules for my cart based on product items weight.

Now, while clicking on checkout all the rules are getting applied. In addition to that i need to show a custom message based on the validation rules while redirecting before checkout.

Can someone help me on this.

For Eg; if the item weight is X, i need to show a message like “You can still add y quantities to the cart”

If the item weight is greater than X, i need to show a message like “Your cart is full”

These messages have to be displayed in the cart before redirecting. How should i do that?

I have created a custom app with cart and checkout extension. I need to display certain messages from the app to the cart page. Can you please let me know how do we display messages to the cart page from the custom app.

Thank you for your response. I am currently working on the option 4, by using server side validation using the cart and checkout extension module.

From there, I can able to send back the error messages. But this message is something, that i just want to display to the user and not block the checkout whereas if i display it as error message it will block the checkout. So, do we have any solution to just display the message based on the rules from server-side.

Thank you for your response. I am currently working on the option 4, by using server side validation using the cart and checkout extension module.

I have to add a message as a cart attribute in cart and checkout validation app and display the same message from the cart attribute using checkout UI extension in the checkout page.

Can someone help me with adding cart attributes in run.js of cart and checkout validation function by adding cart messages inside the attribute values.

Hi @newuser13,

If you never want to block checkout, a validation function is the wrong tool here. They only do one thing, reject the checkout with an error. There’s no advisory mode.

What you’re describing is display logic, and it lives in two places:

  • On the cart page, it’s theme code. Read the line quantities (or weights) and render your message right in Liquid, or with a bit of JS.
  • Inside checkout, it’s a checkout UI extension. It can read the cart and show a banner without blocking anything.

Keep the actual limit values in a metafield or cart attribute so they aren’t hardcoded in two places.

One thing worth knowing before you build: everything in the theme is advisory. If any of these rules ever has to become a hard stop (cart genuinely full), that piece has to move to checkout validation, because the express buttons like Shop Pay skip your cart page entirely and never see the theme logic.