I gang

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.

Færdigheder: PHP, WooCommerce

Se mere: $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

Om arbejdsgiveren:
( 1 bedømmelse ) Nashville, United States

Projekt-ID: #14811330

Tildelt til:

RITESHBATHWAL

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 Mere

$17 USD på 1 dag
(189 bedømmelser)
6.7

3 freelancere byder i gennemsnit $20 for dette job

$25 USD på 1 dag
(25 bedømmelser)
5.2
rajchadokar123

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 på 1 dag
(8 bedømmelser)
3.9