Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Woocommerce 获取可变的产品属性值和名称_Woocommerce_Attributes_Key Value - Fatal编程技术网

Woocommerce 获取可变的产品属性值和名称

Woocommerce 获取可变的产品属性值和名称,woocommerce,attributes,key-value,Woocommerce,Attributes,Key Value,您好,我需要从订单中检索所选变量产品的值,并使用以下代码: $attributes = $product->get_attributes(); $variation_names = array(); if( $attributes ){ foreach ( $attributes as $key => $value) { $variation

您好,我需要从订单中检索所选变量产品的值,并使用以下代码:

            $attributes = $product->get_attributes();
            $variation_names = array();
            if( $attributes ){
                foreach ( $attributes as $key => $value) {
                    $variation_key =  end(explode('-', $key));
                    $variation_names[] = ucfirst($variation_key) .' : '. $value;
                    error_log(print_r(array("VARIATIONNAMES",$variation_names), true));
                }
            }
这样,我可以正确检索名称,但值为空:

[04-May-2021 07:59:21 UTC]阵列 ( [0]=>变量名称 [1] =>阵列 ( [0]=>属性\u pa\u模块: )

)

我找不到原因,你能帮我吗? 多谢各位