Created
September 2, 2022 20:26
-
-
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
This file contains 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
<?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