Created
April 5, 2024 13:38
-
-
Save plugin-republic/b2a5a41d418cdaebce1d2cc2165628ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove quantity input field in cart for specific products | |
*/ | |
function prefix_cart_item_quantity( $product_quantity, $cart_item_key ){ | |
$cart_item = WC()->cart->cart_contents[ $cart_item_key ]; | |
$product_id = $cart_item['data']->get_id(); | |
if( in_array( $product_id, array( 467, 789 ) ) ){ | |
$product_quantity = $cart_item['quantity']; | |
} | |
return $product_quantity; | |
} | |
add_filter( 'woocommerce_cart_item_quantity', 'prefix_cart_item_quantity', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment