从购物车页面中删除Woocommerce购物车数量选择器 [英] Remove Woocommerce cart quantity selector from cart page
问题描述
我正在尝试从购物车页面中删除Woocommerce购物车数量选择器。我在商店档案页面上使用了数量输入字段,并将其应用于购物车页面。我该如何删除它,而不允许用户更改它?
I am trying to remove Woocommerce cart quantity selector from the cart page. I am using the quantity input field on my shop archive pages and it has applied it to the cart page. How can I remove it and not allow the user to change it?
我尝试了以下代码,并从Woocommerce官方文档中进行了研究并发现了该代码,但事实并非如此应用规则...
I have tried the following with the code below, researched and found from official Woocommerce docs but it is doesnt apply the rule...
function wc_remove_quantity_field_from_cart() {
if ( is_cart() ) return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_quantity_field_from_cart', 10, 2 );
推荐答案
您只是错过了 $ return
和 $ product
...下面的函数可以与内置的钩子一起使用。
You were just missing the $return
and $product
from your function...The below function will work otherwise with the built in hook.
function wc_remove_quantity_field_from_cart( $return, $product ) {
if ( is_cart() ) return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_quantity_field_from_cart', 10, 2 );
这篇关于从购物车页面中删除Woocommerce购物车数量选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!