[英]How to remove add to cart button from shop page in woocommerce
I want to remove add to cart button from the shop page, product category page and home page in woocommerce.我想从 woocommerce 的商店页面、产品类别页面和主页中删除添加到购物车按钮。 But i want to show it on the product page.
但我想在产品页面上显示它。 That meance i want my costumers to open product page to add the product to cart.
这意味着我希望我的客户打开产品页面以将产品添加到购物车。
To remove add to cart button from product page.从产品页面删除添加到购物车按钮。 you need to override the product page template .
您需要覆盖产品页面模板。
So locate to woocommerce directory find the below path .所以定位到woocommerce目录找到下面的路径。
wp-content/plugins/woocommerce/templates/content-product.php wp-content/plugins/woocommerce/templates/content-product.php
and remove the text which says - It will remove the Add To Cart Button for each product in the Shop page, retaining the Button in the Single Product Page.并删除文字 - 它将删除商店页面中每个产品的添加到购物车按钮,保留单个产品页面中的按钮。
This worked for me:这对我有用:
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 ); add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
if( is_product_category() || is_shop()) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.