drupaldrupal-7drupal-commerce

drupal commerce order save custom field value


Drupal Commerece, added new custom field in order form, custom field called location, When application creating new order entry that time i want to update location, That is at first when order placed.

When customer adding second and third items, then no more actions on the location field.

Is there any hook will perform the above request.


Solution

  • I would say that best candidate for your request would be hook_commerce_order_presave($order). You can check if the order is just created or updated and optionally discard the location field value.

    If you want to hide that field on order placing form you should use hook_form_alter() to disable or hide that field. Check out how to do this on Drupal 7 - Hide certain form fields of a content edit form depending on the content data.