1

I am using the Drupal commerce module. I want to write a PHP script to execute on order completion, and I want that script to update an external database with the shipping information. How would I go about doing this?

I have already setup a rule to execute PHP code on order completion, and I am given the variable $commerce_order, but I don't know what to call to get out the customer shipping information. I have tried to email var_dump($commerce_order) but it does not give me anything.

How can I get a list of the fields? Am I on the right track?

0

The shipping information isn't directly stored on the order. The only way you have of figuring the shipping details is to look at the line items at $order->commerce_line_items one or more of them will be shipping line items, which can tell you about the shipping details.

  • How can I figgure out what is in $order->commerce_line_items? – Reid Mar 27 '12 at 18:17
0

To write to a second DB you most likely need some custom code. Therfore I sugest to write your own rules action (see http://drupalcontrib.org/api/drupal/contributions!rules!rules.api.php/function/hook_rules_action_info/7)

I'd start with the 'order is payed in full' rules event since it gives you the order and payment transaction object in the $data parameter of the action.

Have a look at the commerce_email module to get a code example for finding the line items of an order.

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.