Skip to content

Instantly share code, notes, and snippets.

@bstonedev
Created March 8, 2020 21:26
Show Gist options
  • Save bstonedev/fd718a51879a52d528898243bf24f5f0 to your computer and use it in GitHub Desktop.
Save bstonedev/fd718a51879a52d528898243bf24f5f0 to your computer and use it in GitHub Desktop.
Override / set / replace / clear WooCommerce checkout page field values
<?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 'new-email@email.com';
}
if($key == 'billing_phone') {
return '0123456789';
}
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment