我正在向 woocommerce 结帐计费部分页面添加 20 个自定义结帐字段。它以前工作正常。但是最近我们发现字段的显示顺序已经混乱了。我希望有人可以帮助我按照添加的顺序显示自定义字段。
我已禁用除 woocommerce 之外的所有插件。我使用的是二十九主题。我删除了所有自定义字段,然后一次添加一个。奇怪的是,我能够添加按顺序显示的 11 个字段。当我们添加 12 个或更多字段时,显示混乱。我用一个简单测试字段的多个副本替换了所有定制的自定义字段,但问题仍然存在。
以下代码已添加到主题 functions.php
add_filter( 'woocommerce_checkout_fields' ,
'custom_override_checkout_fields',10,3 );
function custom_override_checkout_fields( $fields ) {
//unset the unwanted billing fields
unset($fields['order']['order_comments']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);
//add custom fields
$fields['billing']['billing_test1'] = array(
'label' => __('test1', 'woocommerce'),
'placeholder' => _x('', 'placeholder', 'woocommerce'),
'required' => true,
'clear' => true,
'class' => array('form-row'),
);
$fields['billing']['billing_test2'] = array(
'label' => __('test2', 'woocommerce'),
'placeholder' => _x('', 'placeholder', 'woocommerce'),
'required' => true,
'clear' => true,
'class' => array('form-row'),
);
//a further 18 copies of the above field test3->test20
return $fields;
}
布局应该是:-
First name Last name
Email address
test1
test2
test3
....
test20
实际布局是:-
First name
test10
test19
test18
test17
test16
test15
test14
test13
test12
test11
Last name
test9
test8
test7
test6
test5
test4
test3
test2
test1
千万里不及你
郎朗坤
随时随地看视频慕课网APP