Last active
October 10, 2019 19:41
-
-
Save patilvikasj/4d4b3ac566606c926ddec00f23a629c6 to your computer and use it in GitHub Desktop.
Prepopulate Woo-commerce billing email field from GET parameter
This file contains hidden or 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
/** | |
* 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