Single Product – Edit Only 1 left in stock

Woocommerce Single Product Page Snippet

Implementation

1. Either code and paste the code into your themes functions.php or child theme
2. If you are not that technical then install the WordPress Snippets plugin

/**
 * @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 );

View on snippet on GitHub.

NEED HELP?

If you are struggling to implement the SVG snippet then we can help from £9.99 – use our contact form below and we will get straight back to you!

HELP ME IMPLEMENT THIS SNIPPET

Leave a comment

Shares