Last active
March 23, 2021 22:44
-
-
Save WillBrubaker/a69a0e481540208e1258578759d7e812 to your computer and use it in GitHub Desktop.
Override default stock message by product id
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
//not sure what to do with this code snippet? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/ | |
//BTC Donations to: bc1qc2s60yct2aqza4r7ryweheepd8xa8wqpfgdhg3 | |
add_filter( 'woocommerce_get_availability_text', 'handsome_bearded_guy_availability_text', 10, 2 ); | |
function handsome_bearded_guy_availability_text( $availability, $product ) { | |
$oos_replacement_messages = array(//the product id is the array key and the value is the replacement message | |
3871 => 'Here on Thursday', | |
3870 => 'on back order', | |
); | |
return array_key_exists( $product->get_id(), $oos_replacement_messages ) ? $oos_replacement_messages[ $product->get_id() ] : $availability; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment