Skip to content

Instantly share code, notes, and snippets.

@PluginHive
Created October 24, 2019 10:36
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 PluginHive/18fd1a330b1bf5cb1ab332ffc990886a to your computer and use it in GitHub Desktop.
Save PluginHive/18fd1a330b1bf5cb1ab332ffc990886a to your computer and use it in GitHub Desktop.
Hide quantity in cart page
function hide_woocommerce_cart_item_quantity($product_quantity, $cart_item_key, $cart_item) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if($_product->is_sold_individually())
{
$product_type = $_product->get_type();
if( $product_type == 'phive_booking' )
{
$product_quantity = sprintf( '%s <input type="hidden" name="cart[%s][qty]" value="1" />','', $cart_item_key );
}
}
return $product_quantity;
}
add_filter( 'woocommerce_cart_item_quantity', 'hide_woocommerce_cart_item_quantity',10,3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment