簡體   English   中英

WooCommerce-如何僅添加自定義國家/地區以在結帳頁面上進行選擇並保持自動完成功能?

[英]WooCommerce - How to add only custom countries to select on checkout page and keep autocomplete feature?

我必須在結帳頁面的選擇框中僅顯示允許的運輸國家。 我使用以下代碼添加了自定義列表,但它破壞了自動填充功能,並保留了正常選擇(屏幕截圖上的紅色邊框)。

如何僅添加自定義國家/地區並保留自動填充功能?

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' );

在此處輸入圖片說明

我已經解決了,解決方案很簡單:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM