Woocommerce 在获取运输方式时返回空数组列表 [英] Woocommerce is returning empty array list while fetching shipping methods

查看:24
本文介绍了Woocommerce 在获取运输方式时返回空数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个自定义运输方式插件,我需要为其访问运输方式变量.

 echo "

";print_r($woocommerce->shipping->get_shipping_methods);回声"</pre>";

在我的插件中执行此操作会返回一个空集或数组同时,

echo "

";print_r($woocommerce->shipping->get_shipping_methods);回声"</pre>";

返回预期值(可用的运输方式)任何想法是由于某种错误还是什么?

这是我收到的运输对象 -->

WC_Shipping 对象([启用] =>1[shipping_methods] =>大批()[shipping_total] =>0[shipping_taxes] =>大批()[shipping_label] =>[shipping_classes] =>大批()[包] =>大批())

解决方案

我正在使用以下代码段:
$shipping_methods = $woocommerce->shipping->load_shipping_methods();

这会为我返回送货方式.

I am building a custom shipping method plugin for which i need to access shipping method variables .

      echo  "<pre>";
        print_r( $woocommerce->shipping->get_shipping_methods);

      echo"</pre>";

doing this in my plugin is returning an empty set or array while,

echo  "<pre>";
    print_r( $woocommerce->shipping->get_shipping_methods);

  echo"</pre>";

returns expected value(available shipping methods) any ideas is it due to some kind of error or what ?

here is shipping object which am getting -->

WC_Shipping Object
(
    [enabled] => 1
    [shipping_methods] => Array
        (
        )

    [shipping_total] => 0
    [shipping_taxes] => Array
        (
        )

    [shipping_label] => 
    [shipping_classes] => Array
        (
        )

    [packages] => Array
        (
        )

)

解决方案

I am using the following snippet:
$shipping_methods = $woocommerce->shipping->load_shipping_methods();

This returns the shipping methods for me.

这篇关于Woocommerce 在获取运输方式时返回空数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆