Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created February 19, 2021 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webtoffee-git/16e58d75ca3eba43f98f0dfadd242c5e to your computer and use it in GitHub Desktop.
Save webtoffee-git/16e58d75ca3eba43f98f0dfadd242c5e to your computer and use it in GitHub Desktop.
Alter shipping address
add_filter('wf_pklist_alter_shipping_address', 'webtoffee_pklist_alter_shipping_address', 10, 3);
function webtoffee_pklist_alter_shipping_address( $shipping_address, $template_type, $order)
{
if($template_type == 'invoice')
{
$order_id = (WC()->version < '2.7.0') ? $order->id : $order->get_id();
$house_no = get_post_meta($order_id, 'house_no', true);
$shipping_street =$order->get_shipping_address_2();
$shipping_city=$order->get_shipping_city();
$out=array(
'name'=>$shipping_address['first_name'].' '.$shipping_address['last_name'],
'house_no'=>__('House No: ').$house_no,
'town'=>__('Town/City: ').$shipping_city.', '.__('STREET:').$shipping_street,
'country'=>__('Country/Region: ').$shipping_address['country'],
);
$shipping_address=$out;
}
return $shipping_address;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment