Automattic\WooCommerce\Blocks\Domain\Services
CreateAccount::init()
Init - register handlers for WooCommerce core email hooks.
Method of the class: CreateAccount{}
No Hooks.
Return
null
. Nothing (null).
Usage
$CreateAccount = new CreateAccount(); $CreateAccount->init();
CreateAccount::init() CreateAccount::init code WC 9.8.2
public function init() { // Override core email handlers to add our new improved "new account" email. add_action( 'woocommerce_email', function ( $wc_emails_instance ) { // Remove core "new account" handler; we are going to replace it. remove_action( 'woocommerce_created_customer_notification', array( $wc_emails_instance, 'customer_new_account' ), 10, 3 ); // Add custom "new account" handler. add_action( 'woocommerce_created_customer_notification', function( $customer_id, $new_customer_data = array(), $password_generated = false ) use ( $wc_emails_instance ) { // If this is a block-based signup, send a new email with password reset link (no password in email). if ( isset( $new_customer_data['source'] ) && 'store-api' === $new_customer_data['source'] ) { $this->customer_new_account( $customer_id, $new_customer_data ); return; } // Otherwise, trigger the existing legacy email (with new password inline). $wc_emails_instance->customer_new_account( $customer_id, $new_customer_data, $password_generated ); }, 10, 3 ); } ); }