我正在使用WC过滤器来订购帐单字段
筛选器似乎工作正常,但由于未知原因,它会即时恢复为默认顺序。
add_filter("woocommerce_checkout_fields", "custom_order_fields");
function custom_order_fields($fields) {
$order = array(
"billing_first_name",
"billing_last_name",
"billing_country",
"billing_address_1",
"billing_address_2",
"billing_state",
"billing_city",
"billing_phone",
"billing_email"
);
foreach($order as $field)
{
$ordered_fields[$field] = $fields["billing"][$field];
}
$fields["billing"] = $ordered_fields;
$fields['billing_first_name']['priority'] = 10;
$fields['billing_last_name']['priority'] = 20;
$fields['billing_country']['priority'] = 30;
$fields['billing_address_1']['priority'] = 40;
$fields['billing_address_2']['priority'] = 50;
$fields['billing_state']['priority'] = 40;
$fields['billing_city']['priority'] = 70;
$fields['billing_phone']['priority'] = 80;
$fields['billing_email']['priority'] = 90;
return $fields;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。