Skip to content

Instantly share code, notes, and snippets.

@rizalibnu
Last active December 24, 2016 14:45
Show Gist options
  • Save rizalibnu/06fc0112d08ade2559d4ad82b16b1565 to your computer and use it in GitHub Desktop.
Save rizalibnu/06fc0112d08ade2559d4ad82b16b1565 to your computer and use it in GitHub Desktop.
Wordpress function to change Woocommerce In Stock and Out of Stock Text
<?php
/**
* Woocommerce Change In Stock and Out of Stock Text
*
*/
add_filter( 'woocommerce_get_availability', 'rzl_woo_custom_get_availability', 1, 2);
function rzl_woo_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