Created
October 22, 2021 06:21
-
-
Save webtoffee-git/c51ea57feb815f6506062dd475a7159e to your computer and use it in GitHub Desktop.
To alter address formats in invoice (https://www.webtoffee.com/product/woocommerce-pdf-invoices-packing-slips/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //do not copy this line | |
add_filter('wf_pklist_alter_shipping_address','wf_pklist_alter_address_formats',10,3); | |
add_filter('wf_pklist_alter_billing_address','wf_pklist_alter_address_formats',10,3); | |
add_filter('wf_pklist_alter_shipping_from_address','wf_pklist_alter_address_formats',10,3); | |
function wf_pklist_alter_address_formats($address, $template_type, $order) | |
{ | |
if($template_type=='invoice') | |
{ | |
$arr=array($address['country'], $address['postcode'],$address['city'],isset($address['address_1'])?$address['address_1']:$address['address_line1'],isset($address['address_2'])?$address['address_2']:$address['address_line2']); | |
//you can alter separator <br/> in below statement | |
$address['city']=implode($arr, "<br/>"); | |
unset($address['postcode']); | |
unset($address['state']); | |
unset($address['country']); | |
unset($address['address_1']); | |
unset($address['address_2']); | |
unset($address['address_line1']); | |
unset($address['address_line2']); | |
} | |
return $address; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment