如何在WooCommerce订单中获取特定属性的值?
我尝试了以下代码,但我只获取了属性名称。如何获取属性的值?
$items = $order->get_items();
foreach ( $items as $item )
{
$product_id = $item['product_id'];
$product_variation_id = $item['variation_id'];
$variation_data = get_post_meta( $product_variation_id );
foreach ( $variation_data as $name => $value ) {
if ( ! $value )
{
continue;
}
if ( taxonomy_exists( esc_attr( str_replace( 'attribute_', '', $name ) ) ) )
{
$attribute = $variation_data[$name][0];
$value_of_attribute = ???;
}
}
}