In WooCommerce, I am trying to get all the values of a variable product independently of each other.
For example:
I have the attribute size.
Size has three values: size S, size M and size L.
If the product has all the options for size, I want to see the product three times in my output:
- one time with size S,
- one time with size M
- and one time with size L.
With the following code I see which variations I have. Further i did not come unfortunately.
private function readOptions($product) {
$variations = $product->get_children();
foreach ($variations as $variation) {
$single_variation=new WC_Product_Variation($variation);
$this->doLog(print_r($single_variation->get_variation_attributes(), true));
}
}
Does anyone have any idea how to do this?
Thanks.