How to get the shipping address programmatically in drupal commerce - what wrapper should i use?

I need to get the shipping address (shipping country to be precise) programmatically in drupal commerce. I have the $order object. How can i get the shipping address?

EDIT - Ok i did this

 $order_wrapper = entity_metadata_wrapper('commerce_order', $order);  $shipping =  $order_wrapper->commerce_customer_shipping->value(); 

Now i need to wrap it up again, but i don't know the type

$shipping_wrapper = entity_metadata_wrapper(?, $order); 

Whatshould i put instead of the question mark?


Ok i did this in this way

function commerce_shipping_biagetti_service_rate_order($shipping_service, $order) {
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  $shipping = $order_wrapper->commerce_customer_shipping->commerce_customer_address->value();
  //$shipping is an array containing all shipping data

you can use commerce_customer_profile_load($profile_id), the profile id can be fetched from $order->commerce_customer_shipping variable since you have the order object.

Category: 7 Time: 2012-04-23 Views: 10

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.449 (s). 12 q(s)