En cours

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.

Compétences : PHP, WooCommerce

Voir plus : $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

Concernant l'employeur :
( 1 commentaire ) Nashville, United States

N° du projet : #14811330

Décerné à :

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 Plus

17 $ USD en 1 jour
(189 Commentaires)
6.7

3 freelance font une offre moyenne de $20 pour ce travail

25 $ USD en 1 jour
(25 Commentaires)
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 en 1 jour
(8 Commentaires)
3.9