MainWP Community

Force sold Individually if product stock is low in WooCommerce

Force sold Individually if product stock is low in WooCommerce on your child site.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'woocommerce_is_sold_individually', 'wc_product_max_1_cart_stock_low', 9999, 2 );
 
function wc_product_max_1_cart_stock_low( $individually, $product ) {
   if ( $product->get_stock_quantity() < 3 ) {
      $individually = true;
   }
   return $individually;
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.