doulifang5554
2018-08-08 23:30
浏览 97
已采纳

获取woocommerce 3中自定义结帐字段的值

In Woocommerce checkout, I am adding a custom checkout field and here is my code:

add_action( 'woocommerce_before_order_notes', 'shipping_add_select_checkout_field' );
function shipping_add_select_checkout_field( WC_Checkout $checkout ) {
    $options = array_merge( [ '' => __( 'Nothing to select' ), ], city_zone() );
    woocommerce_form_field( 'billing_country_zone', array(
            'type'     => 'select',
            'class'    => array( 'form-row-wide', 'address-field', 'update_totals_on_change' ),
            'label'    => __( 'City zone' ),
            'required' => true,
            'options'  => $options
    ), WC()->customer->billing_country_zone );
}

Now I am totally lost as I need to know what is WC()->customer->billing_country_zone for and how can I check it's value…

Any help is really appreciated.

图片转代码服务由CSDN问答提供 功能建议

在Woocommerce结帐中,我添加了一个自定义结帐字段,这是我的代码: \ n

  add_action('woocommerce_before_order_notes','shipping_add_select_checkout_field'); 
运费shipping_add_select_checkout_field(WC_Checkout $ checkout){
 $ options = array_merge([''=> __('无需选择'),]  ,city_zone()); 
 woocommerce_form_field('billing_country_zone',array(
'type'=>'select',
'class'=> array('form-row-wide','address-field  ','update_totals_on_change'),
'label'=> __('City zone'),
'required'=> true,
'options'=> $ options 
),WC()  - > customer-> billing_country_zone); 
} 
   
 
 

现在我完全迷失了,因为我需要知道什么是 WC() - &gt ; customer-> billing_country_zone for以及如何检查它的值......

非常感谢任何帮助。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题