您好,我需要从订单中检索所选变量产品的值并使用以下代码:
$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] => Attribute_pa_module : )
)
我找不到原因,你能帮我吗? 谢谢