【发布时间】:2021-03-24 11:22:37
【问题描述】:
标题可能看起来很简单,但它表明它是一个必填字段 - 但是允许结帐而不选择选项并且仅显示选择选项。
我正在使用Change WooCommerce checkout country field default option displayed label 回答我上一个问题的代码,这样:
add_filter( 'woocommerce_form_field_country', 'filter_form_field_country', 10, 4 );
function filter_form_field_country( $field, $key, $args, $value ) {
// Only in checkout page for "billing" city field
if ( is_checkout() && 'billing_country' === $key ) {
$search = esc_html__( 'Select a country / region…', 'woocommerce' ); // String to search
$replace = esc_html__( 'Select option to pay correct tax', 'woocommerce' ); // Replacement string
$field = str_replace( $search, $replace, $field );
}
return $field;
}
add_filter( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_country']['label'] = __('Are you purchasing as a Company Y/N or from the UK?', 'woocommerce');
$fields['billing']['billing_country']['required'] = true;
return $fields;
}
有人发现有冲突吗?
【问题讨论】:
标签: php wordpress woocommerce checkout required-field