Created
September 10, 2024 10:09
-
-
Save webtoffee-git/ebf11501f5fefdc88671c89eadb8bbfa to your computer and use it in GitHub Desktop.
Code snippet to remove address fields form shipping "Form address" - By WebToffee(WooCommerce PDF Invoice, Packing Slips, Delivery Notes and Shipping labels)
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 of code | |
add_filter('wf_pklist_alter_shipping_from_address', 'wt_pklist_alter_from_addr', 10, 3); | |
function wt_pklist_alter_from_addr($fromaddress, $template_type, $order) { | |
// Define address fields to remove from the "From" address | |
$address_fields = [ | |
'address_line1', | |
'address_line2', | |
'city', | |
'state', | |
'country', | |
'postcode', | |
]; | |
foreach ( $address_fields as $field ) { | |
if ( ! empty( $fromaddress[$field] ) ) { | |
unset($fromaddress[$field]); | |
} | |
} | |
// Optionally add a new custom field to the "From" address | |
// $fromaddress['new_field'] = 'new field value'; | |
return $fromaddress; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment