1
Answers
Vote up!
0
Vote down!

Checkout custom date field validation

Hi,

I installed the Commerce Fieldgroup Panes module and added a custom date field (for pick-up) to my checkout form.

The thing I would need now is to validate the date field against the current time, such that users are only able to enter tomorrow's date until 7 pm today, and otherwise they can only select a date starting the day after tomorrow.

I've been searching for a few days now, but haven't found any module that fits my needs. Does anyone know a module that can do this? Or can I write something for that myself in PHP or so?

Thanks in advance!
Dylan

Asked by: dylankiss
on March 17, 2013

Comments

Hi,

I had a look at this, and I figured out I can write some custom PHP code based on my field which returns a boolean, so that's fine, but I can't find the right trigger for the event. "Completing the checkout process" doesn't seem to make much sense, since I want to prevent users from completing it until the entered date is valid.

- dylankiss on March 17, 2013

1 Answer

Vote up!
0
Vote down!

I got it to work!

Event:
'After updating an existing commerce order'

Conditions:
'Entity has field: [commerce-order] has field_delivery_date'
AND
'Data comparison: [commerce-order:status] == Checkout: Overview'
AND
'Custom PHP code to check if the given date is valid'

Actions:
'Show a message on the site: Error message'
'Update status of the order to Checkout: Checkout'

Answer by: dylankiss
Posted: Mar 20, 2013