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/9b928a3e78dbe3909702552d7812989e to your computer and use it in GitHub Desktop.
Save Bobz-zg/9b928a3e78dbe3909702552d7812989e to your computer and use it in GitHub Desktop.
Include email address in WooCommerce address output | Part 3
<?php
/**
* Replace {email} shortcode with actual email address
*
* @link https://github.com/woocommerce/woocommerce/blob/5a707f3e74a18af2d7bf14c20ee65e702a119557/includes/class-wc-countries.php#L601
*/
add_filter('woocommerce_formatted_address_replacements', function( $address, $args ) {
// Replace email for billing address
if ( isset( $args['billing_email'] ) )
{
$address['{email}'] = $args['billing_email'];
}
// Replace email for shipping addres
if ( isset( $args['shipping_email']) )
{
$address['{email}'] = $args['shipping_email'];
}
return $address;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment