1

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.

4
  • FYI, per memory wordpress.com 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.org theme, plugin and development or any questions pertaining to .org.
    – 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 1

1

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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