我在woocommerce的myaccounts中的checkout页面和edit address页面中包含了两个自定义字段。问题是,如果从编辑地址页面更改,则两个自定义字段“billing\\u door”和“billing\\u flatname”不会得到更新。下面是我用来显示字段的代码。现在,我如何更新这些字段并将其存储在数据库中。提前感谢
function custom_address_to_edit( $address ) {
global $wp_query;
if ( isset( $wp_query->query_vars[\'edit-address\'] ) && $wp_query->query_vars[\'edit-address\'] != \'billing\' ) {
return $address;
}
if ( ! isset( $address[\'billing_door\'] ) ) {
$address[\'billing_door\'] = array(
\'label\' => __(\'Door No / Flat No\', \'woocommerce\'),
\'placeholder\' => _x(\'Enter your door number\', \'placeholder\', \'woocommerce\'),
\'required\' => true,
\'class\' => array(\'form-row-first\',\'update_totals_on_change\'),
\'value\' => get_user_meta( get_current_user_id(), \'billing_door\', true )
);
}
if ( ! isset( $address[\'billing_flatname\'] ) ) {
$address[\'billing_flatname\'] = array(
\'label\' => __(\'Building Name\', \'woocommerce\'),
\'placeholder\' => _x(\'Enter your building name\', \'placeholder\', \'woocommerce\'),
\'required\' => false,
\'class\' => array(\'form-row-last\',\'update_totals_on_change\'),
\'value\' => get_user_meta( get_current_user_id(), \'billing_flatname\', true )
);
}
return $address;}