Using this code snippet you can allow backorders for certain products.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/** * Returns whether or not the product can be backordered. * * @param $backorders_allowed * @param $product_id * @param $product * @return bool */ function woocommerce_product_backorders_allowed( $backorders_allowed, $product_id, $product ) { return true; } /** * Return the stock status. Should be 'onbackorder' for backorders. * * @param $stock_status * @param $product * @return string */ function woocommerce_product_get_stock_status( $stock_status, $product ) { return 'onbackorder'; } add_filter( 'woocommerce_product_backorders_allowed', 'woocommerce_product_backorders_allowed', 10, 3 ); add_filter( 'woocommerce_product_get_stock_status', 'woocommerce_product_get_stock_status', 10, 2 ); |
How would we modify this to allow backorder for certain categories?