Đã hoàn thành

Woocommerce change in stock text and display variation quantity.

I have a woo-commerce website and I need a customization to the PHP. I want to change the "In Stock" text on a single product page.

I have used this function code:

// Change in/out of stock text

//@LINK [url removed, login to view]

add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);

function custom_get_availability( $availability, $_product ) {

global $product;

$stock = $product->get_total_stock();

if ( $_product->is_in_stock() ) $availability['availability'] = __( $stock . ' Needed!', 'woocommerce');

if ( !$_product->is_in_stock() ) $availability['availability'] = __('Need fullfilled! ', 'woocommerce');

return $availability;


This code works to change the text, however it returns the global stock amount on variable products. For instance if I have a product with 4 variations and I have 10 of each variation it displays as 40 needed, rather than 10 needed for variation 1, 10 needed for variation 2 ...etc.

I would like the code to display the amount in stock for each variation and my custom text.

Kĩ năng: PHP, WooCommerce

Xem nhiều hơn: $product->is_in_stock(), woocommerce check if in stock, woocommerce change out of stock message, woocommerce_get_availability, woocommerce custom stock status, woocommerce remove in stock text, woocommerce is_in_stock(), woocommerce out of stock label, woocommerce product variation image display, change quantity display product listing zen cart, javascript display text clicked, static text change flash, display text flash video, javascript display text div, actionscript static text change

Về Bên Thuê:
( 1 Nhận xét ) Nashville, United States

ID dự án: #14811330

Được trao cho:


Hi Sir, I will make changes in your code so that for variable product it will display the Stock text for all the variation with their corresponding stock as you mentioned in the project description. Relevant Skills an Thêm

$17 USD trong 1 ngày
(189 Đánh Giá)

3 freelancer đang chào giá trung bình $20 cho công việc này

$25 USD trong 1 ngày
(25 Nhận xét)

I have good knowledge in wordpress and woocommerece and plugin customization Relevant Skills and Experience core php , wordpress Proposed Milestones $17 USD - milestones

$17 USD trong 1 ngày
(8 Nhận xét)