Ad
Blank All WooCommerce Shipping Checkout Fields
I came across with this How to blank all WooCommerce checkout fields by default except country? similar question which has an answer code that meet my needs, but this code will blank all woocommerce shipping and also billing checkout field when customer click checkout button.
if I want the shipping fields only to be blank, how the code will looks like?
Ad
Answer
To blank all WooCommerce shipping checkout fields, you will use the following:
add_filter('woocommerce_checkout_get_value', 'checkout_get_value_filter', 10, 2 );
function checkout_get_value_filter( $value, $input ) {
if ( strpos($input, "shipping_") === 0 ) {
return '';
}
return $value;
}
Or also this specifying each related shipping field key:
add_filter('woocommerce_checkout_get_value', 'checkout_get_value_filter', 10, 2 );
function checkout_get_value_filter( $value, $input ) {
$key_fields = array(
'shipping_first_name',
'shipping_last_name',
'shipping_company',
'shipping_country',
'shipping_address_1',
'shipping_address_2',
'shipping_city',
'shipping_country',
'shipping_state',
'shipping_postcode',
);
if ( in_array($input, $key_fields) ) {
return '';
}
return $value;
}
Code goes on functions.php file of your active child theme (or active theme). It should works.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad