Last active
December 24, 2016 14:45
-
-
Save rizalibnu/06fc0112d08ade2559d4ad82b16b1565 to your computer and use it in GitHub Desktop.
Wordpress function to change Woocommerce In Stock and Out of Stock Text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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