Friday 6 March 2015

WooCommerce: Change add to cart text and link to redirect to single product page

Put the following in your theme’s functions.php file.

add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_to_cart_loop' );
 
function change_add_to_cart_loop( $product ) {
    global $product; // this may not be necessary as it should have pulled the object in already
 
    return '<a href="' . esc_url( $product->get_permalink( $product->id ) ) . '">READ MORE</a>';
}


I would recommend to add any custom PHP code or CSS changes to a child theme. This is to prevent the lost of this customization if the parent theme is ever updated automatically.

If you do not know how to create a child theme in WordPress, please reference this link http://codex.wordpress.org/Child_Themes

No comments:

Post a Comment