Getting Shipping Address from WooCommerce Checkout Page?

i'm a little bit stuck.

I've figured out how to retrieve the addresses assigned to a customers profile via the follow:

print_r(WC()->customer);

But I can't for the life of me figure out what the hook or whichever is required in order to get the shipping address that is being used for the calculation of shipping on the order checkout page. Is this something that is possible to get?

Thank you for the help!

Solutions

There are several ways to get the shipping address.

One solution using global $woocommerce:

global $woocommerce;
echo $woocommerce->customer->get_billing_address();
echo $woocommerce->customer->get_billing_city();
echo $woocommerce->customer->get_billing_state();

Another solution using global $current_user:

global $current_user;

$billing_address_1 = get_user_meta($current_user->ID, 'billing_address_1', true);
$billing_city = get_user_meta($current_user->ID, 'billing_city', true);
$billing_state = get_user_meta($current_user->ID, 'billing_state', true);

echo $billing_address_1;
echo $billing_city;
echo $billing_state;

Another solution using WC():

echo WC()->customer->get_billing_address_1();
echo WC()->customer->get_billing_city();
echo WC()->customer->get_billing_state();

Another solution using session:

$customer_data = WC()->session->get('customer');
echo $customer_data['address_1'];
echo $customer_data['city'];
echo $customer_data['state'];

Similar questions

How to conditionally change WooCommerce billing address title if no separate shipping address is entered
My site has two options If you enter both a billing and a shipping address during checkout, then in the order details page in My Account you can see both Billing address and Shipping address titles above the relevant addresses. If you only enter a billing address during checkout, in the order details page in My Account you can only see 'Billing' ad...
Adding newly added fields in billing address and shipping address in order emails woocommerce
In woocommerce order emails i want to custom fields added along with billing address.This is what i am tried.But it is giving error. anybody pls help.
State isn't show in shipping to address in cart page and selected state in are not checked in checkout page or display order received / thank you page
Due to base country and billing or shipping country are same, country aren't show in cart page shipping to area and order received / thank you page, then I apply this filter to show country. and now country is visible but how to display state like that. And the other problem I selected "Burstadt" as a state here but in checkout page Billi...
How to edit Billing Address Label to Shipping Address in the thank you page and customer email?
In my WordPress site after customer place an order a thank you page will be shown This is my thank you page, at the bottom under customer details I want to edit billing address label to Shipping address This is my customer side email in this also at the bottom under customer details I want to change Billing address to Shipping Address I tried editi...
Woocommerce set and unset shipping based on Shipping Address Checked
UPDATED QUESTION AFTER Scriptonomy ANSWER BELOW I have a woocommerce site in which I have a few different shipping options. I need to hide and show these shipping options based on the "Ship to different address button being checked" Using the above code that got from help from Scriptonomy I am getting closer. The problem I am having as this doesn't...
Hide shipping address on WooCommerce orders based on specific shipping methods
I have two flat rates (flat rate:1 and flat rate:2) I would like to hide the "Shipping Address" in WooCommerce Thank you page when "Flat rate:2" shipping method is chosen. Trying to use something based on WooCommerce - Hide shipping address when local pickup is chosen on thankyou page, but I'm stuck. Can anyone give a some tips ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.