Skip to content

Instantly share code, notes, and snippets.

@techskilled
Last active March 23, 2019 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techskilled/10885c021286c0b3911a6def53cc562b to your computer and use it in GitHub Desktop.
Save techskilled/10885c021286c0b3911a6def53cc562b to your computer and use it in GitHub Desktop.
Woocommerce - Single Product – Edit Only 1 left in stock
/**
* @snippet single Product - Edit Only 1 left in stock
* @code https://techskilled.co.uk/snippets/woocommerce-edit-only-1-left-in-stock-single-product-page
* @author https://techskilled.co.uk
*/
function techskilled_edit_left_stock( $text, $product ) {
$stock = $product->get_stock_quantity();
if ( $product->is_in_stock() && $product->managing_stock() && $stock <= get_option( 'woocommerce_notify_low_stock_amount' ) ) $text .= '. Get it today to avoid 5+ days restocking delay!';
return $text;
}
add_filter( 'woocommerce_get_availability_text', 'techskilled_edit_left_stock', 9999, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment