I am writing some php code to update an external database with the shipping and billing information after the order is complete, so I am writing a rule on checkout complete that adds the customer information to the database. I need to figure out what is contained in the variables that I want to use (eg. $commerce_order->???) how would I figure this out, and is there a reference list anywhere that I can use?


If you simply want to find out what is inside $commerce_order then you can use

<?php echo var_dump($commerce_order);?>

I have made a module in the past that did a simerler thing to what you are trying to do. Using Ubercart I created a module that took advantage of the hook_order function.

function myFunction_uc_order($ops, &$arg1, $arg2){
    global $user;
    $userId = $user->uid;
    if ($ops = 'update' && $arg1->order_status == "payment_received" && $arg2 =="completed"){
        $order = uc_order_load($orderId);
        //$order now contains all order information for the current order

This code will be run every time an order is "updated", this includes being created. So inside the if you can add your code to export to your 'external' database.

Hope this helps

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.