Skip to content

Instantly share code, notes, and snippets.

@patilvikasj
Last active October 10, 2019 19:41
Show Gist options
  • Save patilvikasj/4d4b3ac566606c926ddec00f23a629c6 to your computer and use it in GitHub Desktop.
Save patilvikasj/4d4b3ac566606c926ddec00f23a629c6 to your computer and use it in GitHub Desktop.
Prepopulate Woo-commerce billing email field from GET parameter
/**
* Pre-populate Woocommerce checkout fields
*/
add_filter( 'woocommerce_checkout_get_value', 'prepopulate_email_field', 10, 2 );
function prepopulate_email_field( $input, $key ) {
switch ( $key ) {
case "billing_email":
// Modify inf_field_email with your GET paramter from URL.
if( isset( $_GET['inf_field_email'] ) && ! empty ( $_GET['inf_field_email'] ) ) {
return $_GET['inf_field_email'];
}
break;
}
return $input;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment