1

I'm trying to display the state on the packing slip, by using the function $order->get_shipping_city(). But this only shows the "N" character.

In the other hand, if I use the original $this->shipping_address(), it does show the whole address, but in many lines.

I want to display the whole address in one line.

Packing Slip example

[Edited 11/03/19] I can display the complete address with the function:

$this->shipping_address('state');

But this display the address fields in many paragraphs and not in the desired order.

aynber
  • 22,380
  • 8
  • 50
  • 63
Error 404
  • 27
  • 7

1 Answers1

0
    $order = new WC_Order(44); // Test order number
    $country = $order->get_shipping_country();
    echo $order->get_shipping_city();
    $state = $order->get_shipping_state();
    echo WC()->countries->get_states($country)[$state];
    exit;

Tested OK with WooCommerce 3.5.6 and WordPress 5.1

Get more Order details here

mujuonly
  • 11,370
  • 5
  • 45
  • 75
  • Thanks for the reply. Still not working. I'm thinking it's because the languages. I'm using WooCommerce in Spanish, and the "states" (really provences here) are from Argentina. Maybe that type of values are wrong in the traduction. – Error 404 Mar 11 '19 at 13:12
  • I let the final code `Dirección shipping_address_1; ?> shipping_address_2; ?> , shipping_city; ?> (shipping_postcode; ?>) , get_shipping_country(); $state = $order->get_shipping_state(); echo WC()->countries->get_states($country)[$state]; ?> ` – Error 404 Mar 11 '19 at 17:13