 Of course, now we have our fields here, but if I don't choose anything and I choose to place the order, our order actually goes through. However, we had decided that if I choose this payment get with this field, they're supposed to be filled. So we should be getting a display message telling us we didn't put our phone number in here. So that's what we're going to do right now. I'll go back to our code inside our plugin. And then what I'm going to do here is actually add a new hook that we're going to tap into and that is going to be an add action. So I'll duplicate this and this will be an add action. Now the action that we're going to tap into is actually called the check out process. Check out underscore process and we're going to use a similar name to our checkout process. So we don't need to have a priority here and we also don't pass in any arguments. So I'll copy this and then I'll drop it here and add our new function. And our new function, what we're going to do here is actually check for those validations. So let me just make this a little bit clear and say this would be, I'll change this description and then I'll add this as validation. So we'll start the function of the validation of the fields and we'll hook it into our add action here. So we don't need a priority or arguments at the end of the day for this particular add action. The first thing that we do is we're going to say if we did not post, so we have that global variable. So if we did not post, remember we called this particular field phone number and this one paying network. So we'll say if we did not add the phone number, I'll add this in single quotes. And then if we did not set that, that's what we are looking at in terms of our validation. If we did not set that or if it is empty. So I'll copy this and say, oh, it's empty. So we have that. And then we're also going to validate and say if the payment get away is actually pay Leo. So I'll copy this and then come back here. If pay Leo is actually the payment method that we choose, that's what we need to add here. And say if the payment method we've chosen is actually pay Leo and the phone number is not set up as we supposed to have it in our field here. I'll just do this as payment number because our phone number is the same as we have in default our WooCommerce. So I'll change that and say and we've not set the payment number or it is actually empty. Then what we're going to do is we're going to add a WooCommerce add notice. That's what we're going to use. And then we're going to add a message, of course, in single quotes and we'll say, please enter a number that is to be built. So that will be our message. And then the next thing that we're going to do is add a notice type and this one is going to be error so that it is actually read at the end will add a semicolon. So let me first go and try to see how that works for the phone number to set to be true. So if I try to hit place order, we'll see that we get this message coming for this particular part. In order to save that metadata, we shall go for add action and we're going to use a simple WooCommerce hook, which is a WooCommerce checkout, update, order, meta, and then we shall give it a function of take a press. So we'll change this to take a press to make it unique. Give it a priority of 10 and then priority of 10. Then just get one argument, which will be actually the order ID. So I'll terminate this and then I'll copy this here, come down and start up our function. Of course, close this out. What we need to add here is actually the order ID. So give the order underscore ID in here. So what we're going to do is do the basic check again and I'll copy this and edit it here. So I'll say if is set that is if the pain number is set and is not empty just to make it clear. If it is set and it is not empty, then what we're going to do here is actually use WordPress update post meta, which will require a post ID. And we're going to just use the order ID in this case here. And then we shall add a meta key of payment number. And then the value that we're going to add is actually get this. So I'll pass this in and then we shall remove this and terminate the colon here at the end. So this is what we need just update the post meta, give it the order ID, give it the payment number and posting that. So when I come back to my front end, reload this. After filling in all the details that I need to, I'll add in my number. Choose a payment method and then press the order. And once that is done, the order is received. And let's come back to the backend. This time around, check for Lawrence, the new order. The reason we don't see it here, it is saved and it is in our database. But the reason we don't see it here is because we've not displayed it. So we need to use another WooCommerce hook to display it here in the order. So what we're going to do is come back to our code here and then we're going to duplicate this. And I'm going to use this hook which is a WooCommerce admin order data after billing address because we want to place this information after the billing address right here. That's why I'm going to display that data. And then I am going to just get this part of the hook and then just add it to our function name here. And we'll take a priority of 10 and we'll also take in only one argument. So I'll duplicate this here to make it easy. Then I'll change this function name on what we're going to get here is actually we're going to get the order itself. And in here, we'll write all the details that we need when we push this down. We're going to actually echo some HTML and I'll terminate this and say, so we're going to have a paragraph that is closed off. And then inside this paragraph is where we'll have that information. So we'll get our single quotes and then we shall add our two dots, our two full stops to allow us to get this information. So we're going to copy this, of course, take away the semicolon and we're going to change a couple of things here. So this I'll change to true and I'm going to change this and we're going to use now the get post meta data function of WordPress and inside to get the order ID here, we're actually going to get the order that we get there and then we'll change onto it a method which allows us to get the ID. So get the ID and then we add those two brackets to allow us to actually get the order ID. So let me save that, come back to the admin and reload and you will see that we have our number right here. So but it's standing alone and I just need to echo another line just to make it stand out. So I will do this, add translatable lines and then copy a couple of things. We'll just copy this, come back here and drop it here and then we'll say payment phone number, of course, with the two dots to show and then we'll have the number right below. So save that, come back, reload and we have everything showing up right here. The only difference is if we want to make it look like this is we have to wrap it inside a strong tag. So I can just come back here, add a strong tag to this and then I'll just map this out again. After adding a strong tag, you need to close it off, strong, pull this all together and make one line that we are seeing here. So when I save this, come back, reload. You see that we have our phone number and all of this in here. So maybe I'll just add a break tag to finally close it off. So come back, add a br, save, come back, reload and that looks exactly like all the other things. So we have our payment number showing up in our back end and also being saved on the front end. So that's how we add fields. You can try to get all the other fields, see how they look like. You can try to sanitize them, make sure that they fit the bill and they look the path that they're supposed to be. So the final thing that we're going to do is we want to pass this same information also to our invoices and all the other items that go along. So I'm going to duplicate this function here and then I'm going to add a new hook here. So I'll duplicate this and then the hook that we'll use is called WooCommerce order item meta end. So like I've been doing, I'll just copy this since this is very descriptive in itself and have this as our function name changes here. And then we'll give it a priority of 10 and then we'll pass in three different arguments. Now those arguments are one, the item ID. Then we're going to also get the item and then finally we're going to pass in the order. So those are the three pieces of data that we actually need. So once we save this, create a new order, we'll be able to see that even just as we get all this information here, we'll also be able to get it in the invoices, in the receipts and so on. So thank you for watching the video. If you enjoyed it, give it a thumbs up, share it with your friends and consider subscribing if you haven't because there's so much the more that is to come. Don't forget to watch the videos that are coming up inside the links that I share at the end of the video and enjoy yourself, keep safe.