• 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

PHP | "The requested PHP extension bcmath is missing from your system."

How do I refresh a DIV content?

Laravel Sanctum CSRF not authenticating

Encrypt in php and decrypt in Dart(flutter)

Required field only if another field has a value, must be empty otherwise

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

How to submit the custom form data in database in WordPress without plugin using ajax?

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Match csv filenames to table names and import

Get orders by date and status woocommerce

advanced custom fields wordpress custom class

How do I set the maximum php memory limit

How in Laravel run JavaScript code stored in php variable?

How can i update or reset my password without entering email field in laravel-8?

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

About Contact Privacy policy Terms and conditions