【问题标题】:Access array data inside of an object (Wordpress)访问对象内部的数组数据(Wordpress)
【发布时间】:2021-02-28 01:01:32
【问题描述】:
 WC_Product_Attribute 对象
(
    [数据:受保护] => 数组
        (
            [id] => 1
            [名称] => pa_color
            [选项] => 数组
                (
                    [0] => 26
                    [1] => 27
                    [2] => 30
                )

            [位置] => 0
            [可见] => 1
            [变化] => 1
        )

)

如何访问名称、选项等的值

【问题讨论】:

    标签: wordpress woocommerce protected


    【解决方案1】:

    WC_Product_Attribute 对象应有权访问可让您检索受保护数据的方法。

    假设您将WC_Product_Attribute 存储在变量$attribute 中。您应该能够使用$attribute->get_options()$attribute->get_name() 等方法来获取受保护的数据。

    我建议您查看 WooCommerce 文档以获取您可以使用的更全面的方法列表:

    https://woocommerce.github.io/code-reference/classes/WC-Product-Attribute.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-25
      • 2015-05-04
      相关资源
      最近更新 更多