• 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

Zig-zag scan an N x N array

How to create a scheduler application in php

Change the alert text on add to cart action without selected variation in Woocommerce

Send Outlook 2010 email using PHP

how to sort by a custom appended relation to model

Show Custom Data in Woocommerce Order Details Admin Area

How to disable widget block editor of WordPress?

Remove product downloads section in woocommerce email notifications

Laravel Pagination links() not working

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

How to make a foreign key not using primary key

How to add a heading in between checkout fields of WooCommerce

How to change product Image when variables are selected in Shop and Archive Pages?

Prestashop webservice API creating cart rules

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

About Contact Privacy policy Terms and conditions