How to get order id after an order is saved using Drupal Commerce

1.1k views Asked by At

I am trying to get id of an order whenever an order is saved. I want to send it as an email using webform submission. However, I am unable to find any hook or a way to save order whenever an order is saved Drupal Commerce. I have looked at hook_commerce_order_presave ,but it is invoked before an order is saved. Any help and suggestions are appreciated.

Thanks.

1

There are 1 answers

1
nimbfire On

Commerce don't define a specific hook for that. But since the commerce order is an entity, you can use hook_entity_insert and hook_entity_update.

They both have a $type that you can test to see if is an order and a $entity with info if its a new one.

=)