您可以使用woocommerce_after_checkout_validation
用于自定义验证。下面的代码片段可能会对您有所帮助。
//Action to validate
add_action(\'woocommerce_after_checkout_validation\', \'after_checkout_otp_validation\');
//The function
function after_checkout_otp_validation( $posted ) {
// you can use wc_add_notice with a second parameter as "error" to stop the order from being placed
if (error) {
wc_add_notice( __( "Incorrect OTP!", \'text-domain\' ), \'error\' );
}
}