Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change the Out of stock string based on the product's cost
add_filter( 'woocommerce_get_availability_text', 'price_out_of_stock_string', 10, 2 );
function price_out_of_stock_string( $text, $product ) {
if ( $text === 'Out of stock' && $product->get_price() < 100 ) {
return "Out of stock because of The Queen's Gambit";
}
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment