Discussions

Is it possible to get shipping address when calculating cost in calculate_quote() ?

Dear All,

I'm working on a Drupal 7 Commerce project with Commerce Shipping, and I have to calculate the shipping cost according to the "Administrative Area" in my own shipping method. I've tried to search a lot of articles but still haven't solved yet, I can NOT get the Shipping Address information in the Calculate_Quote() function.

Any advices?

Thanks a lot in advance!

Posted: Aug 22, 2011

Comments

neardark on September 13, 2011

Here's how I load an order's address info -- it might help you. Might not.

$order = commerce_order_load($orderNumber);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$billing_address = $wrapper->commerce_customer_billing->commerce_customer_address->value();
$shipping_address = $wrapper->commerce_customer_shipping->commerce_customer_address->value();

Hope this helps,

John McCormick / NEAR DARK