Hello I cant get from woocommerce order shipping address, I get error:
Fatal error: Call to a member function get_formatted_address() on a non-object in ..
I am using code:
$order_data = new WC_Order('12');
print_r($order_data->get_formatted_shipping_address());
There under the customers name you will see a “Users Insights Profile →” link. This links to the WooCommerce customer profile page of the customer who have purchased the order and from there you can get all the customer details that you might need.
We can use the wc_get_endpoint_url function to get the order received page URL. To show this under your order list on the my-account page, you have to edit the template – woocommerce/templates/my-account/orders.
To access the plugin's options menu, go to WooCommerce > Checkout on your WP Admin sidebar. Then select the Force Shipping Address option and adjust it to Yes. On your WooCommerce checkout page, your shipping address should now be visible.
Alternative Way to Finding the IDRight click on the 'Shipping' box of your checkout page when the option you need is available. The option ID can be found nearby in the source code, as seen below.
Here is a workaround
// 123 Happy Coding Lane, Apt #5 Delray Beach, FL 33445
function formatted_shipping_address($order)
{
return
$order->shipping_address_1 . ', ' .
$order->shipping_address_2 . ' ' .
$order->shipping_city . ', ' .
$order->shipping_state . ' ' .
$order->shipping_postcode;
}
echo formatted_shipping_address($order);
You can access the shipping & billing properties directly.
Shipping
$order->shipping_first_name
$order->shipping_last_name
$order->shipping_company
$order->shipping_address_1
$order->shipping_address_2
$order->shipping_city
$order->shipping_state
$order->shipping_postcode
$order->shipping_country
Billing
$order->billing_first_name
$order->billing_last_name
$order->billing_company
$order->billing_address_1
$order->billing_address_2
$order->billing_city
$order->billing_state
$order->billing_postcode
$order->billing_country
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With