Last active
March 10, 2017 13:21
-
-
Save marcosnakamine/91d992d4c44db4041f2eb47fb502cbc1 to your computer and use it in GitHub Desktop.
WooCommerce - Get all variations of product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$product = wc_get_product( get_the_ID() ); | |
$variations = $product->get_available_variations(); | |
print_r( $variations ); | |
/* | |
Array | |
( | |
[0] => Array | |
( | |
[variation_id] => 109 | |
[variation_is_visible] => 1 | |
[variation_is_active] => 1 | |
[is_purchasable] => 1 | |
[display_price] => 90 | |
[display_regular_price] => 100 | |
[attributes] => Array | |
( | |
[attribute_pa_color] => blue | |
[attribute_pa_tamanho] => p | |
) | |
[image_src] => | |
[image_link] => | |
[image_title] => | |
[image_alt] => | |
[image_caption] => | |
[image_srcset] => | |
[image_sizes] => | |
[price_html] => | |
[availability_html] => <p class="stock in-stock">10 em estoque</p> | |
[sku] => 2 | |
[weight] => kg | |
[dimensions] => | |
[min_qty] => 1 | |
[max_qty] => 10 | |
[backorders_allowed] => | |
[is_in_stock] => 1 | |
[is_downloadable] => | |
[is_virtual] => | |
[is_sold_individually] => no | |
[variation_description] => | |
) | |
) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment