Last active
May 24, 2017 08:46
-
-
Save ss2010/5944552abc9515046d8a5e8924e52b5d to your computer and use it in GitHub Desktop.
Change woocommerce add to cart button to custom one
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
| function remove_loop_button(){ | |
| remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); | |
| } | |
| add_action('init','remove_loop_button'); | |
| add_action('woocommerce_after_shop_loop_item','ss_replace_add_to_cart'); | |
| function ss_replace_add_to_cart() { | |
| global $product; | |
| $link = $product->get_permalink();?> | |
| //If want to use button image, you can use custom button text by replacing image to your custom text | |
| <div class="btn"><a href="<?php echo $link;?>"><img src="https://www.yoursite.com/wp-content/uploads/2017/05/btn.png"/></a></div> | |
| <?php | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy this code in your themes functions.php, replace image url or button text with yours