admin管理员组文章数量:1318156
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?
EDIT:
The array receives inside has multiple arrays:
Array ( [attributes] => Array ( [attribute_%d7%9e%d7%99%d7%93%d7%94] => [attribute_%d7%a6%d7%91%d7%a2] => ) [availability_html] => [backorders_allowed] => [dimensions] => Array ( [length] => [width] => [height] => ) [dimensions_html] => N/A [display_price] => 99 [display_regular_price] => 100 [image] => Array ( [title] => sample-slide-1 [caption] => [url] => http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1.jpg [alt] => [src] => http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-600x270.jpg [srcset] => http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-600x270.jpg 600w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-300x135.jpg 300w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-1024x461.jpg 1024w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-768x346.jpg 768w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-1600x720.jpg 1600w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-1536x691.jpg 1536w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-150x68.jpg 150w, http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1.jpg 2000w [sizes] => (max-width: 600px) 100vw, 600px [full_src] => http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1.jpg [full_src_w] => 2000 [full_src_h] => 900 [gallery_thumbnail_src] => http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-100x100.jpg [gallery_thumbnail_src_w] => 100 [gallery_thumbnail_src_h] => 100 [thumb_src] => http://localhost/wordpress/wp-content/uploads/2020/10/sample-slide-1-300x300.jpg [thumb_src_w] => 300 [thumb_src_h] => 300 [src_w] => 600 [src_h] => 270 ) [image_id] => 210 [is_downloadable] => [is_in_stock] => 1 [is_purchasable] => 1 [is_sold_individually] => no [is_virtual] => [max_qty] => [min_qty] => 1 [price_html] => [sku] => [variation_description] => [variation_id] => 309 [variation_is_active] => 1 [variation_is_visible] => 1 [weight] => [weight_html] => N/A )
本文标签: woocommerce offtopicPrinting product variation return array to string conversion error
版权声明:本文标题:woocommerce offtopic - Printing product variation return array to string conversion error 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742041635a2417571.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论