Как я могу получить переменный продукт в шаблоне пользовательской страницы? Я могу получить продукт и изображение или цену, но когда я выбираю атрибуты продукта, он не меняет изображение.
@php
$args = [
'p' => $product_id,
'post_type' => 'product'
];
$single_product_landing = new WP_Query( $args );
global $product;
@endphp
@if ($single_product_landing->have_posts())
@while ($single_product_landing->have_posts()) @php $single_product_landing->the_post() @endphp
@php
$featured_image = get_the_post_thumbnail(get_the_id());
$product = new WC_Product_Variable( $product_id );
$variations = $product->get_available_variations();
@endphp
<div class="py-3 py-md-5 row d-flex content-box align-items-center">
<div class="col-12 col-lg-1 d-lg-block d-none">
<div class="vector">
<h4 class="shadow p-3 bg-dark text-white rounded text-center font-weight-bold">ORDER NOW</h4>
</div>
</div>
<div class="col-12 col-lg-7">
@php
echo wc_get_formatted_variation( $product->get_variation_attributes(), true );
// do_action( 'woocommerce_before_single_product_summary')
foreach ( $variations as $variation ) {
echo "<img src=" . $variation['image']['thumb_src'] .">";
}
@endphp
</div>
<div class="col-12 col-lg-4">
<div class="detail-box shadow p-5 mb-md-5 mb-3 bg-white rounded">
<div class="label shadow text-white mb-2 py-2 px-4 bg-success d-inline-block font-weight-bold">Hot deal</div>
<h2><strong>@php echo $product->get_title(); @endphp</strong></h2>
<p>@php echo $product->get_short_description(); @endphp</p>
@php
do_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
@endphp
</div>
</div>
</div>
@endwhile
@endif
@php wp_reset_postdata() @endphp
![here](https://i.stack.imgur.com/x9hOV.png)