Last active
March 23, 2019 15:42
-
-
Save techskilled/10885c021286c0b3911a6def53cc562b to your computer and use it in GitHub Desktop.
Woocommerce - Single Product – Edit Only 1 left in stock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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