Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xlplugins/43aacbf13c692849e8adaf9a64d7d6c1 to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/43aacbf13c692849e8adaf9a64d7d6c1 to your computer and use it in GitHub Desktop.
create temporary email during checkout
<?php
/**
* Plugin Name: FunnelKit – Temporary Email on Checkout
* Description: Stamp a placeholder email on orders placed without one, so FunnelKit creates the contact.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'woocommerce_checkout_create_order', function ( $order ) {
if ( $order instanceof WC_Order && ! is_email( $order->get_billing_email() ) ) {
$domain = wp_parse_url( home_url(), PHP_URL_HOST );
$order->set_billing_email( 'no-email+' . uniqid() . '@' . $domain );
}
}, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment