Skip to content

Instantly share code, notes, and snippets.

@jamesgol
Created March 28, 2018 20:40
Show Gist options
  • Save jamesgol/e6b8d029d7b87593ba12e5d814734d3a to your computer and use it in GitHub Desktop.
Save jamesgol/e6b8d029d7b87593ba12e5d814734d3a to your computer and use it in GitHub Desktop.
Keep WooCommerce from mentioning backorders unless the item is actually out of stock
add_filter( 'woocommerce_product_backorders_require_notification', 'jmg_backorders_notification', 10, 2 );
function jmg_backorders_notification( $notify, $product = null ) {
if ( $product && 'notify' === $product->get_backorders() && $product->is_in_stock() ) {
return false;
}
return $notify;
}
@jamesgol
Copy link
Author

This all came about because of this post in the WordPress.org forum https://wordpress.org/support/topic/available-on-backorder-2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment