I have shipping methods that will require additional information from the user. For example, a local delivery shipping method which requires the user to include a timeframe for delivery (say, Thursday @ 3pm.)

I thought I'd go about it doing something like this:

  1. On select shipping page during checkout, user selects the delivery date/time (based on what is available.)
  2. User selects date, then submits form.
  3. That date is attached somewhere to the order model.
  4. The shipping method rules will validate the chosen date.
  5. Include this additional information (selected delivery date) in saved order on checkout completion.

Is there a way to do this? Basically, I need to attach additional information for this shipping method (and another similar one.) I've looked through the order model docs but can't find a field I could add custom data to.

1 Answer 1


Add a custom plain text field to your orders, say test.

Then, when calling updateCart, you can add data in to this custom field using a form with an input named like this:

  <input name="fields[test]" type="text"> etc...

This data will then get saved with the order. This same approach can basically be applied to any field/type.

To actually validate the data, you'll need to look to making a plugin, most likely listening to onBeforeSaveOrder to check the vailidity of the data. If valid, great, if not, set perfomAction to false and return an error on the Order model.

See https://craftcommerce.com/docs/events-reference#commerce_orders.onbeforesaveorder

  • I've been trying this but the custom field/val never gets saved to the order model after calling updateCart. Are you saying that I would look for the form's custom field->value through the onbeforesaveorder event and do everything from there? I was hoping there'd simply be a way to just add a new field/value to the order model without any logic from listening to an event.
    – taylor
    Oct 21, 2016 at 19:32
  • You only need the plugin for validation. The field data should save with any update of the cart. Maybe post your input and output code? Oct 21, 2016 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.