• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

phpwordpresswoocommercehook-woocommercestock


PHP Snippet 1:

add_filter( 'woocommerce_get_availability_text', 'filter_product_availability_text', 10, 2 );
function filter_product_availability_text( $availability_text, $product ) {

    if( $product->is_in_stock() && $product->managing_stock() && 
    ! $product-> is_on_backorder( 1 ) && $product->get_stock_quantity() < 10 ) {
        $availability_text .= ' ' . __("(limited supply left)", "woocommerce");
    }
    return $availability_text;
}

Related Snippets

Losing session data after POST from third party website

how to upload binary image to sql server using php laravel

How to remove from a multidimensional array all duplicate elements including the original?

Xdebug in Laravel is not working with VSCode

Display a success custom notice after Placing an Order in WooCommerce

auth pages not getting css in laravel

Laravel whole batch is cancelled if one Job fails

Invalid value in field "itemtype" in Google Search Console

Nginx RTMP not recording

Sentry + Laravel: how to log an already catched Exception?

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

how to get value from array in laravel

Multiple order by in WooCommerce

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

PHP Find Array Index value in multi-line array

About Contact Privacy policy Terms and conditions