Skip to content

Instantly share code, notes, and snippets.

@PluginRepublicSupport
Created January 24, 2023 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PluginRepublicSupport/2911aab4e01dbc65a53941af0cda1b5d to your computer and use it in GitHub Desktop.
Save PluginRepublicSupport/2911aab4e01dbc65a53941af0cda1b5d to your computer and use it in GitHub Desktop.
Disable add-to-cart on WooCommerce shop/archive page
<?php
/**
* Disable the add to cart action
*/
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
/**
* Redirect to product page
*/
add_action( 'woocommerce_after_shop_loop_item', 'shop_more_info_button', 10 );
function shop_more_info_button() {
global $product;
$link = $product->get_permalink();
echo '<a href="' . $link . '" class="button wp-element-button product_type_simple">More Info</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment