• 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

array_key_exists(): The first argument should be either a string or an integer

How do I Post to .txt document before form submits

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

PHPExcel file download using AJAX call

php echo remove slashes from url [duplicate]

PHP random string generator

how to insert data into select2 search input after scan using qrcode

correct PHP headers for pdf file download

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

java URL working on browser but not in client program

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

Smarty if isset

Is there a way to use Foundry Model for Authentification inside Functional Tests?

Check if my GET request has Header: Token

PHP Warning: Module already loaded in Unknown on line 0

About Contact Privacy policy Terms and conditions