admin管理员组文章数量:1122846
On my WooCommerce, I'm trying to hide "Add to cart" button and replace it by a "Contact us" button (with a link to contact page) on specific product page.
I've found different snippets but they don't seem to work anymore :/
Any ideas? :)
Thank you very much!
On my WooCommerce, I'm trying to hide "Add to cart" button and replace it by a "Contact us" button (with a link to contact page) on specific product page.
I've found different snippets but they don't seem to work anymore :/
Any ideas? :)
Thank you very much!
Share Improve this question edited Nov 24, 2018 at 4:08 butlerblog 5,0713 gold badges26 silver badges42 bronze badges asked Nov 6, 2018 at 17:16 SCormanSCorman 111 silver badge3 bronze badges 2- 1 Welcome to WPSE, SCorman. If you found different snippets that you've tried but do not work, you might want to include what you've tried in your question, or at least expand on this so that people know what you've tried. Maybe someone might know why they don't work anymore and can suggest how to change it. – butlerblog Commented Nov 24, 2018 at 0:29
- what do you mean by : on specific product page . by category , by tags, by product type ? ...... – Younes.D Commented Jul 21, 2020 at 21:31
1 Answer
Reset to default 0You can try this. I think it works fine.
/*PUT THIS IN YOUR THEME FUNCTIONS FILE*/
/*STEP 1 - REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */
add_action('init','remove_loop_button');
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
/*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() {
$link = get_permalink(get_page_by_path('contact-us')); //change 'contact-us' to your contact page slug.
echo do_shortcode('<br>[button link="' . esc_attr($link) . '"]Contact us[/button]');
}
本文标签: woocommerce offtopicReplace quotAdd to cartquot by a link to contact page on specific product
版权声明:本文标题:woocommerce offtopic - Replace "Add to cart" by a link to contact page on specific product 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283636a1927029.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论