Skip to content

Instantly share code, notes, and snippets.

@bryceadams
Last active January 28, 2016 20:40
Show Gist options
  • Save bryceadams/382d5c85b835c0d6cd0d to your computer and use it in GitHub Desktop.
Save bryceadams/382d5c85b835c0d6cd0d to your computer and use it in GitHub Desktop.
Use the following code to change the text displayed on a WooCommerce product's page when it is In Stock or Out of Stock. Simply add the following code to the 'custom functions' area of your functions.php file:
<?php
/**
* Change In Stock / Out of Stock Text
*/
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
// Change In Stock Text
if ( $_product->is_in_stock() ) {
$availability['availability'] = __('Available!', 'woocommerce');
}
// Change Out of Stock Text
if ( ! $_product->is_in_stock() ) {
$availability['availability'] = __('Sold Out', 'woocommerce');
}
return $availability;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment