【问题标题】:How to setup Shipping zones based on custom country list in Woocommerce如何根据 Woocommerce 中的自定义国家/地区列表设置运输区域
【发布时间】:2018-05-16 12:29:25
【问题描述】:

我将发货国家/地区列表更改为我自己的:

add_filter( 'woocommerce_countries', 'set_country_list' );
function set_country_list() //changed the method to simplify
{
        $countriesDS = mylist.txt(); //[IT] => 'Italy' as example
        foreach ($countriesDS->rows as $countryDS) {
            $countries[$countryDS->iso_code] = $countryDS->name;
        }
    }
    return $countries;
}

所以,现在当我尝试设置不同的运输区域时,我的一些国家/地区丢失了,一些国家/地区丢失了。

问题:我如何才能在我的列表中仅将国家/地区放入配送区域下拉列表中?

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    这比我想象的要容易得多:

    add_filter( 'woocommerce_continents', 'set_continents_list' );
    function set_continents_list()
    {
        $continents = [
            'R1' => [
                'name' => 'USA/Canada',
                'countries' => [
                    'US',
                    'CA',
                    //your codes of countries
                ]
            ],
            // ...
        ]
        return $continents;
    }
    

    这并没有真正按大洲分组,但我想没什么好担心的

    【讨论】:

      猜你喜欢
      • 2015-09-09
      • 1970-01-01
      • 2018-07-25
      • 1970-01-01
      • 2019-04-08
      • 2020-02-27
      • 1970-01-01
      • 2021-04-24
      • 2019-04-15
      相关资源
      最近更新 更多