Skip to content

Instantly share code, notes, and snippets.

@eltondev
Last active November 24, 2015 11:03
Show Gist options
  • Save eltondev/472dda74dc9100ca3bb5 to your computer and use it in GitHub Desktop.
Save eltondev/472dda74dc9100ca3bb5 to your computer and use it in GitHub Desktop.
Display Button Variable Products WooCommerce
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