Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Last active October 30, 2023 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/88033754a1e5dc7ec91db617e4a6ba5c to your computer and use it in GitHub Desktop.
Save SiR-DanieL/88033754a1e5dc7ec91db617e4a6ba5c to your computer and use it in GitHub Desktop.
Change the Out of stock string based on the product's cost
<?php
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