Skip to content

Instantly share code, notes, and snippets.

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 Bobz-zg/894b0f63888cfb0d18f1b2dc48c734ef to your computer and use it in GitHub Desktop.
Save Bobz-zg/894b0f63888cfb0d18f1b2dc48c734ef to your computer and use it in GitHub Desktop.
Include email address in WooCommerce address output | Part 1
<?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