• 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

Make Calculator - When Button clicked the No shows in Textbox.

how to create html table in php

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

How to MODIFY a Google Docs document via API using search-and-replace?

Display the WooCommerce product price inside a custom function

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

PHPExcel How to set conditional formatting to change cell background color based on cells values

Filter WooCommerce products with post__in and additional meta queries

Getting public posts of a random user from Facebook API

Limit of log line written to Apache Errorlog from mod php error_log

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

PHP array stringify

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

woocommerce change position of price

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

About Contact Privacy policy Terms and conditions