Skip to content

Instantly share code, notes, and snippets.

@ss2010
Last active May 24, 2017 08:46
Show Gist options
  • Select an option

  • Save ss2010/5944552abc9515046d8a5e8924e52b5d to your computer and use it in GitHub Desktop.

Select an option

Save ss2010/5944552abc9515046d8a5e8924e52b5d to your computer and use it in GitHub Desktop.
Change woocommerce add to cart button to custom one
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
}
@ss2010
Copy link
Author

ss2010 commented May 24, 2017

Copy this code in your themes functions.php, replace image url or button text with yours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment