Your cart is currently empty!
Remove Quantity Field When Sold Individually WooCommerce
โ
by
This PHP code removes the quantity field on the single product page when the checkbox on the Inventory tab is checked to Sold Individually.
Add the following PHP code to the end of your child themes functions file or code snippets plugin.
add_action( 'wp', 'remove_quantity_field_for_sold_individually_products' );
function remove_quantity_field_for_sold_individually_products() {
if ( is_product() ) {
global $product;
if ( is_object( $product ) && $product->is_sold_individually() ) {
// Remove the quantity field
remove_action( 'woocommerce_before_add_to_cart_quantity', 'woocommerce_template_single_add_to_cart', 10 );
remove_action( 'woocommerce_after_add_to_cart_quantity', 'woocommerce_template_single_add_to_cart', 10 );
}
}
}
Not exactly what you’re looking for?
Get A Qoute
Free
$0
Access only to all free tutorials per month.
Tutorial Request
Includes code guarantee and coding support.
Monthly
$75
Access to 10 premium tutorials per month.
Tutorial Request
Includes code guarantee and coding support.
Yearly
$500
Access to 15 premium tutorials per month.
Monthly Tutorial Request
Includes code guarantee and priority coding support.
Was This Tutorial Helpful?