Skip to main content

How to Hide WooCommerce Product Quantity Field from Product Pages?

Hide WooCommerce Product Quantity Field from Product Pages


www.wpcodekit.com


function quantity_wp_head() {
 
if ( is_product() ) {
    ?>
<style type="text/css">.quantity, .buttons_added { width:0; height:0; display: none; visibility: hidden; }</style>
<?php
    }
}
    add_action( 'wp_head', 'quantity_wp_head' );


Or



add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields');
function cw_remove_quantity_fields( $return, $product ) {
switch ( $product->product_type ) :
case "grouped":
return true;
break;
case "external":
return true;
break;
case "variable":
return true;
break;
default:
return true;
break;
endswitch;
}




Or




function cw_remove_quantity_fields( $return, $product ) {
    return true;
}
add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields', 10, 2 );




How to Hide WooCommerce Product Quantity Field from Product Pagesd_individually', 'cw_remove_quantity_fields', 10, 2 );

Comments

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...