更新时间:2023-10-25 14:45:58
您只是错过了 $ 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 );