• 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 mail sending empty mails

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Laravel 8: Array to string conversion while calling route:list

How to retrieve Active Directory group policy maximum password age using LDAP

401 Unauthorized only occurring on some pages in Laravel 8

PHP array slice from position + attempt to return fixed number of items

Laravel UUID generation

Explain how this array transposing and flattening function works

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

cakephp save drag and drop list order to database

ldap is missing from system when installing adldap2 in laravel

Display a product custom field only in WooCommerce Admin single orders

Group rows by column and sum another column within groups [duplicate]

ConstraintViolationListInterface to Exception in Symfony

Laravel csrf token mismatch for ajax POST Request

About Contact Privacy policy Terms and conditions