I have taken a print_r of the variable and want access some information from it, heres a preview of the print_r,
WC_Product_Variation Object
(
[variation_data] => Array
(
[attribute_pa_colour] => blue
[attribute_pa_size] => large
)
[sku] => BLUEANDLARGE345
[stock] => 345
)
So if i use the following code:
<td><?php echo $product->sku; ?></td>
<td><?php echo $product->stock; ?></td>
This will echo:
BLUEANDLARGE345
345
How can i echo the variation_data array?
I have tried the following and the output is 'Array':
<td><?php echo $product->variation_data; ?></td>
EDIT:
@pp19dd
So i have tried the following:
<td><?php echo implode(", ", $product->variation_data ); ?></td>
And now the output is:
blue, Test Product Test Product 123
, pink Test Product Test Product 456
yellow, Test Product Test Product 789
blue, large Test Product Test Product 345
The code seems to put a comma after and before, which from the example is not needed.
The blue, pink, yellow, e.t.c is the [variation_data] array.
var_dump($product->variation_data)??Test Product Test Product 123from ?????