【问题标题】:WooCommerce - How to add only custom countries to select on checkout page and keep autocomplete feature?WooCommerce - 如何仅添加自定义国家/地区以在结帐页面上选择并保持自动完成功能?
【发布时间】:2017-05-08 05:16:05
【问题描述】:

我必须在结帐页面的选择框中仅显示允许的送货国家/地区。我使用下面的代码添加了我的自定义列表,但它破坏了自动完成功能并留下正常选择(屏幕截图上的红色边框)。

如何只添加自定义国家并保持自动完成?

function woo_override_checkout_fields( $fields ) {

    $fields['shipping']['shipping_country'] = array(
        'type'      => 'select',
        'required'=>true,
        'label'     => __('Country', 'shop'),
        'options'   => getAllowedCountries()
    );



    $fields['billing']['billing_country'] = array(
        'type'      => 'select',
        'required'=>true,
        'label'     => __('Country', 'shop'),
        'options'   => getAllowedCountries()
    );

    return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'woo_override_checkout_fields' );

【问题讨论】:

    标签: javascript php wordpress woocommerce hook-woocommerce


    【解决方案1】:

    我已经解决了,解决方法很简单:

    $(document).ready(function() {
        $("#billing_country,#shipping_country").select2();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-09
      • 2023-04-07
      • 2016-01-01
      • 2012-09-19
      • 2015-08-18
      • 2015-09-13
      • 1970-01-01
      • 2019-03-20
      相关资源
      最近更新 更多