I am creating a plugin to send a one time password (OTP) to the user when the place order button is clicked. When the user clicks the button, the number from the phone number field must be captured and an API must be called to send the OTP. After that, a page with an input text box to enter the OTP must be present. If the user doesn't verify the order with the OTP, it must not be placed.
I am unable to find any hook to place such a textbox area and for the order placing.
I am creating a plugin to send a one time password (OTP) to the user when the place order button is clicked. When the user clicks the button, the number from the phone number field must be captured and an API must be called to send the OTP. After that, a page with an input text box to enter the OTP must be present. If the user doesn't verify the order with the OTP, it must not be placed.
I am unable to find any hook to place such a textbox area and for the order placing.
Share Improve this question edited Jul 4, 2018 at 16:47 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jun 14, 2018 at 11:20 HarikeshHarikesh 111 silver badge3 bronze badges 4- FYI, per memory wordpress questions aren't in scope with the site. – user9447 Commented Jun 14, 2018 at 13:47
- then what else are allowed in wordpress stackexcange site? – Harikesh Commented Jun 14, 2018 at 15:39
- wordpress theme, plugin and development or any questions pertaining to . – user9447 Commented Jun 14, 2018 at 16:32
- my doubt is regarding plugin development only – Harikesh Commented Jun 15, 2018 at 5:58
1 Answer
Reset to default 1You can use woocommerce_after_checkout_validation
for custom validation. Following snippet might be helpful for you.
//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' );
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742297471a4417413.html
评论列表(0条)