• 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

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Target Laravelista is not instantiable

Performance of foreach, array_map with lambda and array_map with static function

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

How can I get user id from session in javascript?

LARAVEL: How to fetch id dynamically in a query builder?

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

Telegram bot doesn't answer

How to add a heading in between checkout fields of WooCommerce

Multiple order by in WooCommerce

Combining a describing and one array with data

Return multiple values from a function using mysqli_fetch_assoc [closed]

PHP error: "The zip extension and unzip command are both missing, skipping."

Laravel Mix Uncaught ReferenceError: $ is not defined

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

About Contact Privacy policy Terms and conditions