Woocommerce change in stock text and display variation quantity.
$10-30 USD
Completed
Posted over 6 years ago
$10-30 USD
Paid on delivery
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 [login to view URL]
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.
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 and Experience
I have 4 years of experience in woocommerce to do this task perfectly and within 30 mins.
Proposed Milestones
$17 USD - I will customise your code as per your requirements.
$17 USD in 1 day
4.8 (200 reviews)
6.7
6.7
2 freelancers are bidding on average $17 USD for this job
I have good knowledge in wordpress and woocommerece and plugin customization
Relevant Skills and Experience
core php , wordpress
Proposed Milestones
$17 USD - milestones