Skip to content

Instantly share code, notes, and snippets.

@mahdyar
Created September 2, 2022 20:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahdyar/f41e869f6337c66aeef8e58a802dd2b6 to your computer and use it in GitHub Desktop.
Save mahdyar/f41e869f6337c66aeef8e58a802dd2b6 to your computer and use it in GitHub Desktop.
Hide the default "Add to cart" button and show a customized "Add to cart" button in WooCommerce
<?php
/*
*
* Customized add to cart button for WooCommerce
* © mahdyar.me (hasanpour@mahdyar.me)
*
* Add this to the end of your template's "functions.php" file (without "<?php" at the begining of this file)
*
*/
// to hide the default add to cart button
add_filter( 'woocommerce_is_purchasable', '__return_false');
// to show a customized add to cart button
add_action( 'woocommerce_single_product_summary', 'custom_button_after_product_summary', 30 );
function custom_button_after_product_summary() {
echo "<!-- Custom add-to-cart button! -->";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment