Last active
September 16, 2015 23:25
-
-
Save nickburne/192609fedc540654fd9b to your computer and use it in GitHub Desktop.
Replace add to cart button with button to product page - WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*PUT THIS IN YOUR CHILD THEME FUNCTIONS FILE*/ | |
/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */ | |
function remove_loop_button(){ | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); | |
} | |
add_action('init','remove_loop_button'); | |
/*STEP 2 -ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */ | |
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('<br>[button link="' . esc_attr($link) . '"]Read more[/button]'); | |
} | |
hello :)
it isn't working with me !
Thanks for your try to help 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this code doesn't work any more can you please review it