$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>validation - wooCommerce checkout page StateCounty (optional) validate not working|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

validation - wooCommerce checkout page StateCounty (optional) validate not working

matteradmin9PV0评论

wooCommerce checkout page State / County (optional) validate not working

that is my added code

 add_filter(‘thwcfd_State_field_override_required’,’__return_true’);

any idea for how to add mandatory for the State / County (optional)

like as State / County (optional)*

look my issue

wooCommerce checkout page State / County (optional) validate not working

that is my added code

 add_filter(‘thwcfd_State_field_override_required’,’__return_true’);

any idea for how to add mandatory for the State / County (optional)

like as State / County (optional)*

look my issue

Share Improve this question edited Nov 30, 2018 at 9:03 core114 asked Nov 30, 2018 at 8:49 core114core114 11512 bronze badges 7
  • 1 hi ok i send solution for you – vikrant zilpe Commented Nov 30, 2018 at 8:55
  • 1 please send state/ country field name – vikrant zilpe Commented Nov 30, 2018 at 9:16
  • 1 See this, function SA_woocommerce_states( $states ) { $states['LK']['CK'] = __('Colombo', 'woocommerce'); $states['LK']['RT'] = __('Kandy', 'woocommerce'); return $states; } – core114 Commented Nov 30, 2018 at 9:17
  • 1 Sri, yesterday you given n some solution for me, look wordpress.stackexchange/questions/320546/… – core114 Commented Nov 30, 2018 at 9:19
  • this shipping form? – vikrant zilpe Commented Nov 30, 2018 at 9:26
 |  Show 2 more comments

1 Answer 1

Reset to default 1

Code goes in function.php file of your active child theme (or active theme). It could works.

add_filter( 'woocommerce_billing_fields', 'woo_filter_state_billing', 10, 1 ); 
function woo_filter_state_billing( $address_fields ) { 
    $address_fields['billing_state']['required'] = true;
    return $address_fields; 
} 

add_filter( 'woocommerce_shipping_fields', 'woo_filter_state_shipping', 10, 1 );
function woo_filter_state_shipping( $address_fields ) { 
    $address_fields['shipping_state']['required'] = true; 
    return $address_fields; 
}
Post a comment

comment list (0)

  1. No comments so far