Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plugin-republic/b2a5a41d418cdaebce1d2cc2165628ff to your computer and use it in GitHub Desktop.
Save plugin-republic/b2a5a41d418cdaebce1d2cc2165628ff to your computer and use it in GitHub Desktop.
<?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