Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Created January 22, 2014 15:35
Show Gist options
  • Save EricBusch/8560844 to your computer and use it in GitHub Desktop.
Save EricBusch/8560844 to your computer and use it in GitHub Desktop.
Replaces "Buy" button with "More Details" button on list of products (WooCommerce). For example on category pages.
<?php
/**
* Removes the "Buy" button from list of products (ex. category pages).
*/
add_action( 'woocommerce_after_shop_loop_item', 'mycode_remove_add_to_cart_buttons', 1 );
function mycode_remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
/**
* Adds a "More Details" button on list of products (ex. category pages).
*/
add_action( 'woocommerce_after_shop_loop_item', 'mycode_add_more_info_buttons', 1 );
function mycode_add_more_info_buttons() {
add_action( 'woocommerce_after_shop_loop_item', 'mycode_more_info_button' );
}
function mycode_more_info_button() {
global $product;
echo '<a href="' . get_permalink( $product->id ) . '" class="button add_to_cart_button product_type_external">More Details</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment