mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/77152979/remove-quantity-field-everywher-for-a-specific-product-in-woocommerce
9 lines
446 B
Text
9 lines
446 B
Text
add_filter( 'woocommerce_is_sold_individually', 'remove_all_qty_fields_on_specific_product', 10, 2 );
|
|
function remove_all_qty_fields_on_specific_product( $sold_individually, $product ) {
|
|
// Here define the desired product Id(s)
|
|
$targeted_product_ids = array( 90 );
|
|
if ( count(array_intersect([$product->get_id(), $product->get_parent_id()], $targeted_product_ids) ) > 0 ) {
|
|
return true;
|
|
}
|
|
return $sold_individually;
|
|
}
|