Last active
November 24, 2015 11:03
-
-
Save eltondev/472dda74dc9100ca3bb5 to your computer and use it in GitHub Desktop.
Display Button Variable Products WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_before_add_to_cart_button' , 'woocommerce_before_add_to_cart_button_variation' ); | |
function woocommerce_before_add_to_cart_button_variation() { | |
global $woocommerce, $product, $post; | |
if ( empty( $available_variations )) { | |
echo '<button id="newbutton" type="submit" class="single_add_to_cart_button button alt">' . $product->single_add_to_cart_text() . '</button>'; | |
} | |
} | |
add_action( 'woocommerce_after_add_to_cart_form' , 'woocommerce_after_add_to_cart_form_remove_button', 1000 ); | |
function woocommerce_after_add_to_cart_form_remove_button() { | |
echo "<Script>"; | |
echo "var myBTN = document.getElementById('monitorthisspace');"; | |
echo "myBTN.addEventListener('click', function() {"; | |
echo "document.getElementById('newbutton').style.display = 'none';"; | |
echo "}, false);"; | |
echo "</Script>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment