×
Black Friday Savings
00Days
:
03Hours
:
56Minutes
:
45Seconds
Use Coupon 40%OFF

Includes 1 Year Priority Support

Shop Now

WP SITES

3093 Coded Tutorials & 297 Plugins

Remove Quantity Field When Sold Individually WooCommerce

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

Was this helpful?

Yes
No
Thanks for your feedback!

Leave a Reply