2

I would like to be able to see which country the product was ordered from, even if it is from the origin country.

The location where I would like to show the origin country:

text So in the picture above it does show the country as long as it is not the same country as the country the store address is set to.

Is there any way to remove this limitation without ruining the possibility for automatic updates?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
AHG
  • 33
  • 3

1 Answers1

3

You can use the following hooked function for that:

add_action( 'woocommerce_admin_order_data_after_shipping_address', 'ordered_origin', 10, 1 );
function ordered_origin( $order ){
    $country_code = $order->get_shipping_country();
    $wc_countries = WC()->countries;

    // Get the shipping coutry code
    $shipping_country_name = $wc_countries->countries[$country_code];

    echo '<p><strong>'.__('Ordered origin').':</strong> ' . $shipping_country_name . '</p>';
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Thank you so much! this does indeed fix the issue, but can i instead of posting the country tag "DK" as an example, type out the entire country name "Denmark"? – AHG Mar 06 '18 at 08:58
  • Thanks too… I have just maid an update to get the shipping country name instead of the code. – LoicTheAztec Mar 06 '18 at 09:00
  • Thanks, but is there any chance I could get this info BEFORE the customer note, right after the post code? It looks like this now: https://i.postimg.cc/GtHmMYGj/image.png Similar problem with the billing country: https://i.postimg.cc/pV4GXFqb/image.png – err Feb 02 '21 at 12:08