在结帐页面上使用下面的代码。圣地亚哥已经被选中了,这不是我想要的。我希望默认位于Seleccione Destino上。
奇怪的是,当我将圣地亚哥的数字从1更改为44,然后它正确工作时,它选择0作为默认值。当圣地亚哥为1时,默认设置为圣地亚哥。
我也尝试过制作默认的1287,但它仍然以1作为默认的第一个。
add_filter( 'woocommerce_billing_fields', 'add_field', 20, 1 );
function add_field($billing_fields) {
$billing_fields['billing_area'] = array(
'label' => __('Ubicación del Destino', 'woocommerce'),
'required' => true,
'type' => 'select',
'default' => 0,
'class' => array('select'),
'priority' => 65,
'options' => array(
0 => 'Seleccione Ubicación', 1 => 'SANTIAGO', 1287 => 'ACHAO'
)
);
return $billing_fields;
}发布于 2020-04-23 15:01:06
这应该能起作用
function add_field($billing_fields) {
$billing_fields['billing_area'] = array(
'label' => __('Ubicación del Destino', 'woocommerce'),
'required' => true,
'type' => 'select',
'default' => 'seleccione_ubicación',
'class' => array('form-row-wide'),
'priority' => 65,
'options' => array(
'seleccione_ubicación' => 'Seleccione Ubicación',
'santiago' => 'SANTIAGO',
'achao' => 'ACHAO'
)
);
return $billing_fields;
}
add_filter( 'woocommerce_billing_fields', 'add_field', 10, 1 );https://stackoverflow.com/questions/61389752
复制相似问题