Support » Plugin: WooCommerce Print Invoice & Delivery Note » Change order of postcode and city in address

  • The output of the shipping and the delivery address shows the city first and then in the next line the postcode. I need to change the order so that the postcode is on the same line with the city and that the postcode comes first.

    The address should look like the following example:
    Peter Miller
    Teststreet 12
    3232 (Postcode) New York (City)

    How can i change the order of the output? Thanks for your help and best regards.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Rashmi Malpande

    (@rashmim)

    Hi @peesen87

    You can change the format of the shipping address using a filter called ‘wcdn_address_shipping’.

    Add the following code in your theme’s functions.php file –

    add_filter( 'wcdn_address_shipping', 'change_address_shipping' , 10, 2 );
    
    function change_address_shipping(  $shipping_address, $order ) {
    	$countries_obj = new WC_Countries();
    	$countries = $countries_obj->get_countries();
    	$states = $countries_obj->get_states();
    
    	$shipping_country = $order->get_shipping_country();
    	$shipping_state = $order->get_shipping_state();
    
    	$shipping_address  = $order->get_formatted_shipping_full_name();
    	$shipping_address .= "<br>". $order->get_shipping_address_1();
    	$shipping_address .= "<br>". $order->get_shipping_address_2();
    	$shipping_address .= "<br>".$order->get_shipping_postcode()." - ". $order->get_shipping_city();
    	$shipping_address .= "<br>". $states[$shipping_country][$shipping_state];
    
    	return $shipping_address;
    }

    You can change the format from here. Let me know if this worked for you.

    Regards,
    Rashmi

Viewing 1 replies (of 1 total)
  • The topic ‘Change order of postcode and city in address’ is closed to new replies.