Created
November 9, 2018 16:20
-
-
Save markbain/8b095e42b8dd1024624f5e54d2b2b5c2 to your computer and use it in GitHub Desktop.
Woocommerce custom availability #wordpress #woocommerce
This file contains 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
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 . ' places remaining', 'woocommerce'); | |
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