• 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

How to find phpcs current default standard

Laravel: HTML in notification

Add custom text under order details on WooCommerce My account view order pages

Whats the point of running Laravel with the command 'php artisan serve'?

Cut an arabic string

How to update array value in Laravel

html-php form submission after validation through JavaScript [closed]

Create a new line whenever an array value reaches more than 10 characters

How to Display Data in Yajra Datatables Laravel 7?

How to create custom authentication in laravel 8?

How to modify CSS in a specific page of the WP admin dashboard (backend)

MISSING UPDATES FOR: MEDIA Drupal 9

How can I get data from PHP to Android TextView?

echo language construct is discouraged. (PHP)

The difference when using if statement true === something() vs something() === true [duplicate]

About Contact Privacy policy Terms and conditions