Solved

Checkout validation

tlb_mk
Shopify Partner
3 0 1

I would like to implement a checkout validation to prevent users to complete purchase when any products in their cart matche a certain case in checkout page.

 

I attempted to do this by using shopify function (https://shopify.dev/docs/apps/checkout/validation/create-simple-validation-rules), but I realized that the validation is also executed when users add a item into the cart.

I know this sounds good in most cases, but not for my store theme, because the cart.liquid is fully customized using js.  It does not seem to be feasible to display returned error message in proper section of my cart.liquid.

 

So, I would like to know if it is possible to run the validation only in checkout page, but not in cart modal.

 

I am still learning about all the checkout extensibility stuff.

I hope I get some answer for this.

Thanks.

Accepted Solution (1)

Philip_Crumpton
Shopify Partner
4 1 3

This is an accepted solution.

I found this answer on another thread after having the same issue.

 

https://community.shopify.com/c/shopify-apps/how-can-i-use-cart-and-checkout-validation-function-to-...

 

There is a buyerJourneyStep that you can use to see if they're on "CHECKOUT_INTERACTION"

View solution in original post

Replies 3 (3)

Philip_Crumpton
Shopify Partner
4 1 3

This is an accepted solution.

I found this answer on another thread after having the same issue.

 

https://community.shopify.com/c/shopify-apps/how-can-i-use-cart-and-checkout-validation-function-to-...

 

There is a buyerJourneyStep that you can use to see if they're on "CHECKOUT_INTERACTION"

tlb_mk
Shopify Partner
3 0 1

Hi, Philip.

 

Thanks!! It solves my problem!!

Philip_Crumpton
Shopify Partner
4 1 3

Glad I could help! I just now discovered you should also check for "CHECKOUT_COMPLETION" for compatibility with one-page checkout. CHECKOUT_INTERACTION apparently doesn't trigger on one-page checkout when clicking Pay Now.