简体   繁体   English

从WooCommerce商店页面删除数量字段

[英]Remove quantity field from WooCommerce shop page

I implemented on my e-commerce the variations choose in shop page in the content-product.php : 我在电子商务中实现了在content-product.php商店页面中选择的变体:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_quantity_input', 30 );
/*remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart_quantity', 30 );*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );              
do_action( 'woocommerce_single_product_summary' ); 
?>

I want to remove the quantity selector from home page. 我想从主页删除数量选择器。 How can I remove it using remove_action ? 如何使用remove_action删除它?

Try with this hook in functions.php file 尝试使用functions.php文件中的此钩子

/**
 * @desc Remove in all product type
 */
function wc_remove_all_quantity_fields( $return, $product ) {
    return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );

You can do it without any scripts or coding. 您可以执行此操作,而无需任何脚本或代码。

WP-Admin -> Products -> Open your product -> Select Inventory -> Select "Sold Individually". WP-Admin->产品->打开产品->选择库存->选择“单独出售”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数量字段添加到 WooCommerce 商店页面上的 Ajax 添加到购物车按钮 - Add a quantity field to Ajax add to cart button on WooCommerce shop page 如何从WooCommerce中的购物车页面中删除数量 - How to remove quantity from cart page in WooCommerce 删除侧边栏商店页面woocommerce - remove sidebar shop page woocommerce 如何从woocommerce商店页面中删除指向产品页面的链接 - How to remove link to product page from woocommerce shop page 添加数量单选字段到 Ajax 添加到 WooCommerce 商店页面上的购物车按钮 - Add a quantity radio selector field to Ajax add to cart button on WooCommerce shop page woocommerce_quantity_input() 在商店页面 woocommerce 上不起作用 - woocommerce_quantity_input() not working on shop page woocommerce 在产品类别页面中从WooCommerce产品过滤器隐藏或删除数量字段 - Hide or remove the quantity field from WooCommerce Product filter in product-category page 如何从购物车页面中删除特定产品属性WooCommerce的数量字段 - How to remove the quantity field from cart page for specific product attribute WooCommerce PHP Woocommerce Flatsome 主题 - 从商店页面标题中删除面包屑 - PHP Woocommerce Flatsome theme - Remove breadcrumb from shop page title Woocommerce - 从商店页面中删除可用的产品库存编号 - Woocommerce - Remove the available product inventory number from the shop page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM