久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何獲得 WooCommerce 運(yùn)輸方式的成本和設(shè)置?

How to get WooCommerce shipping methods cost and settings?(如何獲得 WooCommerce 運(yùn)輸方式的成本和設(shè)置?)
本文介紹了如何獲得 WooCommerce 運(yùn)輸方式的成本和設(shè)置?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我正在嘗試獲取所有運(yùn)輸方式及其費(fèi)率和標(biāo)題.但是當(dāng)我使用 WC()->shipping->get_shipping_methods() 時(shí),它只會(huì)返回空的費(fèi)率數(shù)組和空的標(biāo)題字符串.這是一個(gè)轉(zhuǎn)儲(chǔ):

I'm trying to get all shipping methods, with their rates and title. But when i use WC()->shipping->get_shipping_methods() it will only return empty rates array, and empty title string. Here is a dump:

     array (size=3)
  'flat_rate' => 
    object(WC_Shipping_Flat_Rate)[1861]
      protected 'fee_cost' => string '' (length=0)
      public 'supports' => 
        array (size=3)
          0 => string 'shipping-zones' (length=14)
          1 => string 'instance-settings' (length=17)
          2 => string 'instance-settings-modal' (length=23)
      public 'id' => string 'flat_rate' (length=9)
      public 'method_title' => string 'Flat rate' (length=9)
      public 'method_description' => string 'Lets you charge a fixed rate for shipping.' (length=42)
      public 'enabled' => string 'yes' (length=3)
      public 'title' => string '' (length=0)
      public 'rates' => 
        array (size=0)
          empty
      public 'tax_status' => string '' (length=0)
      public 'fee' => null
      public 'minimum_fee' => null
      public 'instance_id' => int 0
      public 'instance_form_fields' => 
        array (size=3)
          'title' => 
            array (size=5)
              ...
          'tax_status' => 
            array (size=5)
              ...
          'cost' => 
            array (size=7)
              ...
      public 'instance_settings' => 
        array (size=0)
          empty
      public 'availability' => null
      public 'countries' => 
        array (size=0)
          empty
      public 'plugin_id' => string 'woocommerce_' (length=12)
      public 'errors' => 
        array (size=0)
          empty
      public 'settings' => 
        array (size=4)
          'title' => string '' (length=0)
          'tax_status' => string '' (length=0)
          'cost' => string '' (length=0)
          'type' => string 'class' (length=5)
      public 'form_fields' => 
        array (size=0)
          empty
      protected 'data' => 
        array (size=0)
          empty
      public 'cost' => string '' (length=0)
      public 'type' => string 'class' (length=5)

我試圖用谷歌搜索這個(gè)問(wèn)題,但沒(méi)有任何幫助.有誰(shuí)知道可能是什么問(wèn)題?

I tried to Google the issue, but nothing really helped. Does anyone know what could be the issue?

非常感謝!

推薦答案

因?yàn)?WC()->shipping->get_shipping_methods() 不會(huì)加載在每個(gè)運(yùn)輸區(qū)域,它只加載您可以在任何運(yùn)輸區(qū)域設(shè)置的所有可用運(yùn)輸方式,以及所有默認(rèn)值和可用的設(shè)置字段......

Because WC()->shipping->get_shipping_methods() doesn't load the shipping methods that are set on each shipping zone, it just loads all available shipping methods that you can set in any shipping zone, with all default values and available fields for settings…

請(qǐng)記住,運(yùn)輸方式成本和設(shè)置按運(yùn)輸區(qū)域設(shè)置,并且與位置(地區(qū)、國(guó)家/地區(qū)、州或郵政編碼)相關(guān).

Remember that shipping methods costs and settings are set by shipping zone and are related to locations (Region, country, state or postcode).

因此,由于每個(gè)送貨區(qū)域的送貨方式費(fèi)率不同,您需要首先獲得在送貨部分設(shè)置中設(shè)置的一個(gè)或所有送貨區(qū)域.

So as shipping methods rates are different for each shipping zone you need to get first, one or all shipping Zones that are set in shipping section settings.

然后,您可以從運(yùn)輸區(qū)域獲得為其設(shè)置的所有運(yùn)輸方式費(fèi)率,例如:

Then from a shipping zone you can get all shipping methods rates that is set for it like:

// Get all your existing shipping zones IDS
$zone_ids = array_keys( array('') + WC_Shipping_Zones::get_zones() );

// Loop through shipping Zones IDs
foreach ( $zone_ids as $zone_id ) 
{
    // Get the shipping Zone object
    $shipping_zone = new WC_Shipping_Zone($zone_id);

    // Get all shipping method values for the shipping zone
    $shipping_methods = $shipping_zone->get_shipping_methods( true, 'values' );

    // Loop through each shipping methods set for the current shipping zone
    foreach ( $shipping_methods as $instance_id => $shipping_method ) 
    {
        // The dump of protected data from the current shipping method
        var_dump($shipping_method);
    }
}

這一次,正如您將看到的,您將獲得在配送區(qū)域中設(shè)置的每種配送方式費(fèi)率的所有設(shè)置(自定義標(biāo)簽、成本和其他設(shè)置).

This time, as you will see, you get all settings (custom label, costs and other settings) for each shipping method rate set in a shipping zone.

這篇關(guān)于如何獲得 WooCommerce 運(yùn)輸方式的成本和設(shè)置?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗(yàn)證問(wèn)題中添加自定義注冊(cè)字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡(jiǎn)單產(chǎn)品中添加一個(gè)將更改價(jià)格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 精品免费国产视频 | 最新日韩在线 | 麻豆毛片 | 99精品国产一区二区青青牛奶 | 国产日韩欧美在线 | 91精品国产91 | 免费毛片网站在线观看 | 欧美日韩在线一区二区 | 亚洲欧洲精品在线 | 中文字幕av亚洲精品一部二部 | 欧美日韩亚洲国产综合 | 亚洲福利| 日韩成人免费中文字幕 | 嫩草视频网 | 久久久久久亚洲精品 | 国产乱码精品一区二三赶尸艳谈 | 草草视频在线观看 | www.色五月.com | 亚洲精品乱码久久久久久按摩观 | 久久成人精品 | 亚洲第一福利视频 | 九九久久久 | 91久久精品日日躁夜夜躁欧美 | 日韩一级免费电影 | 国产伦精品一区二区三毛 | 狠狠操操 | 国产一区二区三区 | 亚洲免费精品 | av手机在线播放 | 亚洲精品久久嫩草网站秘色 | 看片天堂| 羞视频在线观看 | 中文字幕在线一区二区三区 | 性做久久久久久免费观看欧美 | 黄网站在线观看 | 成人国产精品免费观看 | 亚洲精品中文字幕av | 我我色综合 | 一区二区三区精品在线视频 | 草在线| 黄色免费三级 |