Created
March 8, 2020 21:26
-
-
Save bstonedev/fd718a51879a52d528898243bf24f5f0 to your computer and use it in GitHub Desktop.
Override / set / replace / clear WooCommerce checkout page field values
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
<?php | |
/** | |
* Pre-populate Woocommerce checkout fields | |
* Note that this filter populates shipping_ and billing_ fields with a different meta field eg 'first_name' | |
*/ | |
add_filter('woocommerce_checkout_get_value', function($input, $key ) { | |
if($key == 'billing_first_name') { | |
return 'NEW FIRST NAME'; | |
} | |
if($key == 'billing_last_name') { | |
return 'NEW LAST NAME'; | |
} | |
if($key == 'billing_email') { | |
return '[email protected]'; | |
} | |
if($key == 'billing_phone') { | |
return '0123456789'; | |
} | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment