Created
February 12, 2021 09:05
-
-
Save Bobz-zg/894b0f63888cfb0d18f1b2dc48c734ef to your computer and use it in GitHub Desktop.
Include email address in WooCommerce address output | Part 1
This file contains hidden or 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 | |
/** | |
* Append email to address format | |
* | |
* @link https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-countries.php#L510 | |
*/ | |
add_filter( 'woocommerce_localisation_address_formats', function( $formats ) { | |
// Double quotes in sprintf() or \n will not be parsed as a new line character | |
$formats['default'] = sprintf("%s\n{email}", $formats['default']); // Default | |
$formats['FI'] = sprintf("%s\n{email}", $formats['FI']); // Country specific | |
/** | |
* In case you want to put in a specific position you could use str_replace(), eg: | |
* | |
* $formats['default'] = str_replace( "{name}\n", "{name}\n{email}\n", $formats['default'] ); | |
*/ | |
return $formats; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment