Printing product variation return array to string conversion error

Question

I’m trying to echo product variation data using Woocommerce plugin.

I have the following code that suppose to parse array using foreach loop:

$variableProduct = wc_get_product(get_the_ID());

$allVariations = $variableProduct->get_available_variations();
foreach ($allVariations as $key => $value) 
{ 
    echo $value;
}

But instead I’m receiving

Notice: Array to string conversion

How to print product variations correctly?

0
Yotam Dahan 2 years 2020-10-23T04:10:23-05:00 0 Answers 7 views 0

Leave an answer

Browse
Browse