Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Created November 3, 2017 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rynaldos-zz/fffac2366e49a11610fd15e29eb73ed4 to your computer and use it in GitHub Desktop.
Save rynaldos-zz/fffac2366e49a11610fd15e29eb73ed4 to your computer and use it in GitHub Desktop.
[WooCommerce 3.0+] Change Add to cart button on archive page + open product page instead of adding to cart
add_action('init','remove_loop_button');
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
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">Choose options</a>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment