Created
February 12, 2021 09:16
-
-
Save Bobz-zg/9b928a3e78dbe3909702552d7812989e to your computer and use it in GitHub Desktop.
Include email address in WooCommerce address output | Part 3
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 | |
/** | |
* 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