Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created March 7, 2014 19:21
Show Gist options
  • Save raphaelchaib/9418049 to your computer and use it in GitHub Desktop.
Save raphaelchaib/9418049 to your computer and use it in GitHub Desktop.
WooCommerce: Change add_to_cart button to "Read More" button
<?php
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'cg_loop_add_to_cart', 10 );
function cg_loop_add_to_cart() {
// global $product;
// echo '<form action="' . esc_url( get_permalink( $product->id ) ) . '" method="get">
// <button type="submit" class="single_add_to_cart_button button alt">View More</button>
// </form>';
global $product; // this may not be necessary as it should have pulled the object in already
echo '<a href="' . esc_url( get_permalink( $product->id ) ) . '" class="single_add_to_cart_button button alt">Read More</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment