Skip to content

Instantly share code, notes, and snippets.

@mdrovdahl
Created March 28, 2024 22:29
Show Gist options
  • Save mdrovdahl/211d7af5267f81c9202e6f39c1d6ac59 to your computer and use it in GitHub Desktop.
Save mdrovdahl/211d7af5267f81c9202e6f39c1d6ac59 to your computer and use it in GitHub Desktop.
Filter the product stock availability message in WooCommerce to use "registration" centric language
// Modify the stock availability message to use "registration" centric language
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'] = __('Registration Is Open', 'woocommerce');
}
// Change Out of Stock Text
if ( ! $_product->is_in_stock() ) {
$availability['availability'] = __('Registration Is Full', 'woocommerce');
}
return $availability;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment