N
N
Nohaga2019-09-28 08:44:56
WooCommerce
Nohaga, 2019-09-28 08:44:56

How to choose a product variation?

I manually display products, how can I display the variation selection so that it is taken into account when adding the product to the cart?

$args = array(
'tax_query' => array(
'relation' => 'AND', 
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'bouquet'
),
),
'posts_per_page' => 99, 
'post_type' => 'product', 
'orderby' => 'title', 
);

$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
global $product;	
?>				
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
<?php endwhile; ?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question