Created
March 20, 2019 19:01
-
-
Save morvy/0306a4f79fcde07d465bf66e9ed83fe8 to your computer and use it in GitHub Desktop.
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
/** | |
* Blocks order if condition is met | |
* - blocks Emma Rose orders | |
* - blocks orders from New York | |
* | |
* @param array $data | |
* @param object $errors | |
* @return void | |
*/ | |
function pmo_custom_checkout_field_validation( $data, $errors ) { | |
if( strtolower($data['billing_first_name']) == "emma" && strtolower($data['billing_last_name']) == "rose" ) { | |
$errors->add('validation', 'Sorry, Emma Rose is not allowed to make orders. If you think this is an error, contact us by email.'); | |
} | |
if(strtolower($data['billing_city']) == "new york") { | |
$errors->add('validation', 'Sorry, New York is too far for us to deliver, find a dealer closer to your location.'); | |
} | |
} | |
add_action( 'woocommerce_after_checkout_validation', 'pmo_custom_checkout_field_validation', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment