Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 08:28
Show Gist options
  • Save bradleysa/4b9ac054155c1904239d9fd8e7e6e971 to your computer and use it in GitHub Desktop.
Save bradleysa/4b9ac054155c1904239d9fd8e7e6e971 to your computer and use it in GitHub Desktop.
WC: Change "Out of stock" to "Sold Out" on Single Product
add_filter( 'woocommerce_get_availability', 'change_out_of_stock_text_woocommerce', 1, 2 );
function change_out_of_stock_text_woocommerce( $availability, $product_to_check ) {
// Change Out of Stock Text
if ( ! $product_to_check->is_in_stock() ) {
$availability['availability'] = __('Sold Out', 'woocommerce');
}
return $availability;
}
/** https://wpastra.com/docs/change-woocommerce-out-of-stock-text/ **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment