WooCommerce: always showing add-to-cart button even before variation is selected -


on single product page of variable products, woocommerce doesn't generate add-to-cart button until 1 variation gets selected. if 2 variations required 1 selected, wc still generates button clicking triggers error message asking select variations.

apart fact don't understand logic (why using post-submit error message second variation , different solution - no-submit-button 1 - first?), there way show add-to-cart button @ times, post-submit error message if not variations selected ?

this should job:

add_action( 'woocommerce_before_add_to_cart_button', function(){     // start output buffering     ob_start(); } );  add_action( 'woocommerce_before_single_variation', function(){     // end output buffering     ob_end_clean();     // output custom div     echo '<div class="single_variation_wrap_custom">'; } ); 

practically i've intercepted (inside template file single-product/add-to-cart/variable.php) html tag <div class="single_variation_wrap" style="display:none;"> affected via javascript choices of user, , replaced <div class="single_variation_wrap_custom"> not.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -