Skip to content

Instantly share code, notes, and snippets.

@DanielSantoro
Created August 28, 2015 21:36
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 DanielSantoro/4b350f520130e13f23d2 to your computer and use it in GitHub Desktop.
Save DanielSantoro/4b350f520130e13f23d2 to your computer and use it in GitHub Desktop.
Change "Add to Cart" Button to go to product page
/*PUT THIS IN YOUR CHILD THEME FUNCTIONS FILE*/
/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');
/*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */
add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">View Product</a>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment