I also think that there will be a much higher conversion rate if the add to cart button is always visible. my task: always show the button. if no selection is selected, display an error message ("select an option") by clicking. this is how I DECIDED IT. All you need to do is edit functions.php functions: For this, I use the second "fake" button. so first we insert this button:
function wc_custom_addtocart_button(){
global $product;
?>
<a href="#" class="btn btn-primary btn-block placeholder_button"><?php echo $product->single_add_to_cart_text(); ?></a>
<?php
}
add_action("woocommerce_before_add_to_cart_button","wc_custom_addtocart_button");
Then we switch the visibility using custom js code:
function run_js_code(){
if (get_post_type() == "product"):
?>
<script>
jQuery(document).ready(function($) {
$(document).on( 'found_variation', function() {
$(".single_add_to_cart_button").show();
$(".placeholder_button").hide();
});
$(".variations_form").on( 'click', '.reset_variations', function() {
$(".single_add_to_cart_button").hide();
$(".placeholder_button").show();
});
$(".placeholder_button").click(function(e){
e.preventDefault();
alert("Please choose a product variation!");
});
});
</script>
<?php
endif;
}
add_action( 'wp_footer', 'run_js_code' );
i css:
.single_add_to_cart_button { display: none; }
, woocommerce .