简体   繁体   English

如何从woocommerce的商店页面中删除添加到购物车按钮

[英]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.

相关问题 Woocommerce商店页面(类别页面模板)添加到购物车按钮行为 - Woocommerce shop page (category page template) Add to cart button behavior 将数量字段添加到 WooCommerce 商店页面上的 Ajax 添加到购物车按钮 - Add a quantity field to Ajax add to cart button on WooCommerce shop page 在 Woocommerce 3 商店页面上的添加到购物车下添加额外按钮 - Add Extra button under Add to cart on shop page of Woocommerce 3 在结帐时添加一个按钮以清空购物车并重定向到Woocommerce中的商店页面 - Add a button in checkout to empty cart and redirect to shop page in Woocommerce WooCommerce商店页面:添加到购物车按钮上的数量输入 - WooCommerce Shop page: Quantity input on add to cart button 在Woocommerce商店页面中更改用于简单产品的购物车按钮 - Change add-to-cart button for simple products in Woocommerce shop page 更改商店页面中 woocommerce 商店中“添加到购物车”按钮的重定向 - Changing the redirect of the “add to cart” button in woocommerce store in Shop page 如何在自定义页面(不是商店/产品页面)上添加到购物车按钮 Woocommerce - How to make add to cart button on custom page (not shop/product page) Woocommerce woocommerce 商店页面,如何通过“添加到购物车”按钮添加自定义价格 - woocommerce shop page, how to add custom price via "add to cart" button 从“清空购物车”页面移除或隐藏 WooCommerce“返回商店”按钮? - Removing or hiding WooCommerce "Return to Shop" button from 'empty cart' page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM