As for the Woocommerce archive pages ( categories) of goods output variation if it is a variable product?

Good time of day.
Use a plugin for WooCommerce Variation swatches from Emran Ahmed to add variations to the product.
I had the task to bring variations from the catalog ( archive ) not to go to the product page. Found the snippet :
 * Replace add to cart button in the loop.
iconic_change_loop_add_to_cart function() {
 remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
 add_action( 'woocommerce_after_shop_loop_item', 'iconic_template_loop_add_to_cart', 10 );

add_action( 'init', 'iconic_change_loop_add_to_cart', 10 );

 * Use single add to cart button for variable products.
iconic_template_loop_add_to_cart function() {
 global $product;

 if ( ! $product->is_type( 'variable' ) ) {

 remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
 add_action( 'woocommerce_single_variation', 'iconic_loop_variation_add_to_cart_button', 20 );


 * Customise variable add to cart button for loop.
 * Remove the qty selector and simplify.
iconic_loop_variation_add_to_cart_button function() {
 global $product;

 <div class="woocommerce-variation-add-to-cart variations_button">
 <button type="submit" class="single_add_to_cart_button button"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
 <input type="hidden" name="add-to-cart" value="<?php echo absint, the hotel's( $product->get_id() ); ?>" />
 <input type="hidden" name="product_id" value="<?php echo absint, the hotel's( $product->get_id() ); ?>" />
 <input type="hidden" name="variation_id" class="variation_id" value="0" />

It turned out so:
How to conclude on a human and to change images when choosing variations on the product page?
I would be grateful if anyone can help with the decision
April 3rd 20 at 18:34
0 answer

Find more questions by tags WordPressWooCommerce