Table of Contents
- 1) Plugin Deceleration
- 2) call js file
- 3) Js file code
- 4) Create phone_verification table and delete on plugin activation and deactivation
- 5) Create function sms_send
- 6) Admin menu for SMS gateway setting
- SMS API Details
- 7) Send OTP function
- 8) function for Check is valid OTP
- 9) Add 2 fields phone and otp on registration page
- 10) add user meta 'billing_phone' on new user register
- 11) Send SMS to customer phone and admin phone when new order place
Woocommerce have lots of default functionalities for a powerful eCommerce website . Nowadays OTP verification is commonly required in lots of
website for 2 factor authentication . Also to send SMS to customer's and admin's phone when new order place.
In this tutorial, I will guide you how to create a plugin for verifying user's phone no. with OTP and send order details to customer and admin phone no. Now lets start coding for the WordPress, Woocommerce SMS Integration plugin .
Now activate our newly created plugin from WordPress admin dashboard plugin's page . If you encounter any error, let me know in below comment . I will try my best to reply . Well, I am a WordPress freelance Developer from Delhi, India. You can contact me on webmaster.delhi1@gmail.com .
In this tutorial, I will guide you how to create a plugin for verifying user's phone no. with OTP and send order details to customer and admin phone no. Now lets start coding for the WordPress, Woocommerce SMS Integration plugin .
1) Plugin Deceleration
Lets create a plugin folder ex: 'SMS-Integration' and file 'sms_integration.php' inside our wp-contents/plugin folder ex: SMS-Integration/sms_integration.php Now put below plugin information
2) call js file
Now we require to add our plugin's js file 'phone_verification.js' . So put below code in our plugin
Note: above we creates a folder 'js' inside our plugin folder and added a file 'phone_verification.js'
This is jquery's code .So, we mentioned above in array 'jquery' . So that WordPress load our js file after jquery .3) Js file code
Below code of our phone_verification.js file
4) Create phone_verification table and delete on plugin activation and deactivation
To do so, put below code in our plugin
5) Create function sms_send
Now we will create sms_send function, It contains SMS gateway API details . You can obtain this information where you purchase SMS gateway. Put this function in our plugin
6) Admin menu for SMS gateway setting
Now we need to create WordPress admin menu . Put below code in our plugin
We have made dynamic to mention SMS gateway information on above form .Also option for test SMS.7) Send OTP function
Now put send_otp function in our plugin as mentioned below
This function used by our js file for ajax otp send when user enter his/her phone no.8) function for Check is valid OTP
We need to check if OTP entered by user is valid or not. So, we have to put below code in our plugin .
9) Add 2 fields phone and otp on registration page
10) add user meta 'billing_phone' on new user register
11) Send SMS to customer phone and admin phone when new order place
Now activate our newly created plugin from WordPress admin dashboard plugin's page . If you encounter any error, let me know in below comment . I will try my best to reply . Well, I am a WordPress freelance Developer from Delhi, India. You can contact me on webmaster.delhi1@gmail.com .