0

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.

  • FYI, per memory wordpress.com questions aren't in scope with the site. – DᴀʀᴛʜVᴀᴅᴇʀ Jun 14 '18 at 13:47
  • then what else are allowed in wordpress stackexcange site? – Harikesh Jun 14 '18 at 15:39
  • wordpress.org theme, plugin and development or any questions pertaining to .org. – DᴀʀᴛʜVᴀᴅᴇʀ Jun 14 '18 at 16:32
  • my doubt is regarding plugin development only – Harikesh Jun 15 '18 at 5:58
0

You 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' );
    }

}
  • My otp will be sent if the proceed checkout button is clicked,where can be the textbox for otp kept? – Harikesh Jun 15 '18 at 5:56
  • you can try to play around with this, or maybe you can generate the OTP before place order action. – Akshat Jun 15 '18 at 6:44
  • I can't understand where to write the html text box. – Harikesh Jun 15 '18 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.