问题描述
我正在尝试打印我在帐单地址中创建的新字段,但是我无法使其显示出来,它仅出现在我的帐户中,但是在“谢谢”页面上查看时,没有任何显示。
这是我正在使用的代码
add_filter( 'woocommerce_billing_fields','rut_checkout_field' );
function rut_checkout_field( $billing_fields ) {
$billing_fields['billing_rut'] = array(
'type' => 'text','label' => __("RUT (con puntos y guión)","woocommerce"),'class' => array('form-row-wide'),'placeholder' => _x('12.345.678-9','placeholder','woocommerce'),'required' => true,'priority' => 25,'maxlength' => 12,);
return $billing_fields;
}
// Printing the Billing Address on My Account
add_filter( 'woocommerce_my_account_my_address_formatted_address','custom_my_account_my_address_formatted_address',10,3 );
function custom_my_account_my_address_formatted_address( $fields,$customer_id,$type ) {
if ( $type == 'billing' ) {
$fields['billing_rut'] = get_user_Meta( $customer_id,'billing_rut',true );
}
return $fields;
}
// Checkout -- Order Received (printed after having completed checkout)
add_filter( 'woocommerce_order_formatted_billing_address','custom_add_vat_formatted_billing_address',2 );
function custom_add_vat_formatted_billing_address( $fields,$order ) {
$fields['billing_rut'] = $order->get_Meta('billing_rut');
return $fields;
}
add_filter( 'woocommerce_formatted_address_replacements','custom_formatted_address_replacements',2 );
function custom_formatted_address_replacements( $replacements,$args ) {
$replacements['{billing_rut}'] = ! empty($args['billing_rut']) ? $args['billing_rut'] : '';
$replacements['{billing_rut_upper}'] = ! empty($args['billing_rut']) ? strtoupper($args['billing_rut']) : '';
return $replacements;
}
add_filter( 'woocommerce_localisation_address_formats','bbloomer_new_address_formats' );
function bbloomer_new_address_formats( $formats ) {
$formats['CL'] = "{company}\n{name}\n{billing_rut}\n{address_1}\n{address_2}\n{state}\n{postcode} {city}\n{country}";
return $formats;
}
参考图片
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)