$args = array(
'post_type' => 'product_variation',
'post_status' => array( 'private', 'publish' ),
'numberposts' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => get_the_ID() // get parent post-ID
);
$variations = get_posts( $args );
foreach ( $variations as $variation ) {
// get variation ID
$variation_ID = $variation->ID;
// get variations meta
$product_variation = new WC_Product_Variation( $variation_ID );
// get variation featured image
$variation_image = $product_variation->get_image();
// get variation price
$variation_price = $product_variation->get_price_html();
//get variation name
$variation_name = $product_variation->get_variation_attributes();
echo "<p class='product_price' >";
if ( $variation_name [ 'attribute_pa_СЛАГ_АТРИБУТА' ] ) {
$fasovka = [ 'attribute_pa_СЛАГ_АТРИБУТА' => $variation_name [ 'attribute_pa_СЛАГ_АТРИБУТА'] ];
echo wc_get_formatted_variation ( $fasovka );
}
echo ($variation_price);
echo "</p>";
}
// Спойлер для списков фильтра
var maxLi = 10, text = ["Скрыть", "Показать еще"];
$("ul.checkbox").each(function() {
var li = $(this).find("li");
if (li.length > maxLi) {
li = li.slice(maxLi).hide();
var btn = $("<div>", {
text: text[1],
"class": "btn gray see-more",
click: function() {
li.stop().slideToggle(500, function() {
btn.text(text[+$(this).is(":hidden")])
})
}
}).appendTo(this)
}
});