Developer forum

Forum » Ecommerce - Standard features » Require order reference

Require order reference

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I am trying to require users to enter a PO number on an order. I want to use the standard Order reference field for that. Here's what I set up:

1. Configure the field in Validation groups under Settings:



2. Add the group to my cart settings:

3. And assigned the error message



That all looks like it should but now on check out, the PO number is required immediately in the Information step, even though the PO number field isn't shown until the Payment step.

How do I link validation groups to specific checkout steps?

Imar


Replies

 
Karsten Thuen Dynamicweb Employee
Karsten Thuen
Reply
This post has been marked as an answer

Hi Imar,

I have tested and confirmed the issue. 

This is how cart validation currently works. Validation groups are checked every time the customer moves to another step, and they can't be tied to a specific step. For a logged-in customer, a field that isn't on the current step is validated against the value already saved on the order. The order reference is still empty on the Information step, so the error shows there, before the field is visible.

Two workarounds, in your own copies of the Swift templates:

1. Move the field to the Information step (recommended). This keeps server-side validation.

Move @Include("Helpers/OrderReference.cshtml") from PaymentUser.cshtml and PaymentAnonymous.cshtml to InformationUser.cshtml and InformationAnonymous.cshtml, after the address include.
In Helpers/StepSummaryOrderReference.cshtml, change CartV2.GotoStep2 to CartV2.GotoStep0, so the Edit button goes to the Information step.

2. Keep it on the Payment step. Remove Order reference from the validation group and add required to the input in Helpers/OrderReference.cshtml. This is a browser check only, so it can be bypassed.

Note that field validation is configured on the checkout app paragraph, not the cart's. In Swift that means each checkout page (user, anonymous and quote) needs it set up separately.

Best regards
Karsten Thuen

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Karsten. Both work arounds aren't great, but I think it is what it is for now. Maybe we can have validation tied to checkout steps one day? Would it make sense to submit a feature request for that?

Imar

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

We are currently building a new checkout app - for viewmodels.

Very different beast - we can have a look at it in that context.

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks, Nicolai, that would be great.

 

You must be logged in to post in the forum