I can manage to get the order shipping address in MY_MODULE_calculate_shipping (price depends on shipping country) when the buyer is logged in.

When he is anonymous, I can't find information about the shipping address in the $order object ...

Could someone tell me what I'm missing ?

Comments

guy_schneerson’s picture

I had the same problem, I think the issue is that the address gets saved after the calculate shipping is called, if you are logged in you will get an address if it is already saved, so if you changed the country from UK to France the calculate_shipping will see UK.

The way I got around this is by capturing the address information using the hook_form_alter, but its not the most elegant of solutions.

googletorp’s picture

Status: Active » Fixed

I have create a solution for this, by adding the $form and $form_state values to the calculate function. This will hold all values submitted along with the shipping method. This along with the order object itself should provide the info needed.

Please test and let me know if this doesn't work for you.

Commit: 50a8838

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

1kenthomas’s picture

Status: Closed (fixed) » Active

Sorry, per http://drupal.org/node/1262678; I looked at those and with the shipping pane displaying below the billing pane, $form etc. did not have address data available.

googletorp’s picture

Status: Active » Closed (fixed)

#4 You have the $form_state ($pane_values) available, so you can access any value that has been submitted.

It's not necessarily easy or pretty to do so, but it should make you able to get the job done.

I try to give as much info to shipping methods as possible but am limited by the FAPI and the Drupal Commerce pane system. If you feel something is wrong, this is where you should raise the issue. As I see it commerce shipping cannot do anything more in this area.