 Welcome back to the channel. Today I'm going to show you how to add bulk action in here that allows you to change your status from one to another. And then when you go inside your different orders, you should be able to have a new status which says a invoiced or shipping or something like that depending on your own needs because your store could be different. WooCommerce allows us to add our own statuses so we'll be able to add our own shipping or invoiced kind of status inside our WooCommerce. So let's jump into what the code will look like. So in here I have my plugin that I've installed. I'm just going to create a new file and I'll call it a take a price WooOrderStatus.php And what I'm going to do is I'm going to open up my PHP and then I'll just copy and paste what is needed. So we're going to call this a new WooOrderStatus. We'll just call it invoiced. They take a price invoiced WooOrderStatus and then I'll just copy this name here and then just throw it down inside my description. And I'll save this and we are ready to go. So the first thing that we're going to do is we're going to tap into our actions and we're going to use the init hook to say for what prices initialize. Then we're going to add the function or a callback that we're going to have. And we're going to call it a register my invoiced order status underscore status. So I'll copy this come back here and then I'll run this function. So we'll have this function callback and then have a parenthesis coming in. And I'll save this for now. We're going to use the register post status, which is a WordPress function. And this takes in about two arguments for now that we shall need. One is the ID, which I'm going to call a WooWC invoiced. And then the next thing we're going to do is we're going to add an array of arguments that we need. So in this array, we're going to, first of all, I'll close this off with a semicolon. And now I'm going to add a label. So I'm going to add a label first of all, but I will add it in quotations. So we have our label and then we'll mark to it. We shall just say we'll leave it translatable. So we'll add an X here and say we're going to call it invoiced. And then we shall say it's an order status, also in quotes, order status. And then finally, we shall add our string, our text domain string. So add two quotations and then paste in our, and then paste in our text domain. The next thing that we need, first of all, add a comma. We shall know if it is public. Do we need it to be public? And that will be true. And then the next thing that we shall do is exclude it from such. So exclude from such false. And then we shall show in all admin list list for singular and we shall make that true. And then we shall show in admin status list. So basically we want it to be shown in the administration area. So that will be true. And then the other thing that we want to do is we want to add a label count. And basically we're also going to have to translate that, but we'll use the WordPress function of n, and then add our brackets there. And inside here we're going to, of course, have it invoiced. And then we shall add a span. Inside our span, we shall add a class of count. So we have a count in here. And then we're going to add a string that has a cent s. This is basically going to show the number of orders that have, what WooCommerce will automatically calculate for us. That's why we have that in a span of count. Now we're going to add a comma and say again invoiced. We are basically going to do the same thing all over again. So I'll just copy that and paste it here. We're just going to do the same thing all over. That's why I've copied and pasted. And then we shall have our text domain also brought in here again. So I'll copy this and then I'll just add it here and save. So let me get some real estate from here. Okay, comma, we missed a closing bracket here when we translated this. So the next thing that we need to do after initializing and registering our post here, we are now going to use the add filter action hook. And what that will allow us to do is actually add in our statuses that are existing, we're going to be able to add our new status that we have registered. So we're going to use the hook of our WC order statuses, which is a WooCommerce book. And then we're going to add in our new status. So I'll just get this my invoice status and I'll use that as a function for now. So come back here and write our function. Of course, it's named. So I have to add its name. Then what we're going to do here is that this filter passes to us the order statuses. So we just need to tap into that. So order statuses. And then what we're going to do here is first of all return it and then above here, we can actually now add our new order status. So I'm going to order status. Of course, in that array, I'm going to pass in the WC invoice. So basically we're getting our ID from here and then passing it here. And then what we're going to do is translate that as well. So add an X, of course, terminate this before the return. And then what we're going to do is actually just copy this label here. Then change it here. I have an error here. I'm supposed to use a semicolon, not a comma. So after writing, after adding a semicolon, what we're going to do is actually we need to come back to our plugin section here and activate our plugin here so that when we come to add a new order, right now we have a new status which is actually called invoiced. And that is readily available. However, when we go to the order section here and let's say we want to expand this out and we want to do a bulk action, we cannot change the status from whatever status this is to invoiced. And that is because we need to actually plug that in. So what we're going to do is come back to our code here and then we are going to add that to our bulk functionality. So we're going to be writing JavaScript. So what I'll do is I'll just add the... I'll use the add action and this time around we're going to use the hook which is admin underscore footer. So basically we are saying let this run with admin footer. Inside the administration only, let's add this. So what we're going to do we're going to... I'll give it a name and just say add to bulk actions order. So we'll write this function now and then just do this. So write functions and then make ready. So we're going to add a global and say we want it to be the global post type because we're going to restrict this to only work with a particular post type. So we'll say if our post type is actually equal to shop order. So WordPress works with this reverse kind of thing. It's more advisable to do that. So if shop order is equal to double equals and then we shall add our post type, then we shall do something. What we're going to do here is first of all, let's keep the PHP then run the PHP again. So that's the rest of our code can terminate altogether. Now we're going to add some script and then close off our script. Now inside our script, we first of all have to tell you what kind of type it is. It's a type of text slash Java script. So inside our JavaScript, we are going to add jQuery and then we'll add the option. That option is going to have a particular value. So we'll add dot value and we shall say mark as invoiced. And then now we're going to append dot text. And so we're going to basically add our text in there. And then finally we're going to append it to our selection. So in our text, what do we want our text as? First of all, I'm going to escape it as I'm going to write it in PHP so that we can be able to translate it. Let's say when we send it to someone else to use it, maybe in France or in Italy and they want to change the language. So that's why we translate it. So I'm going to use this default WordPress function and then of course we shall append our text domain here. So I'll add the text domain first. Then I can say change status to invoiced so that it can look like all the others. Change status to processing change status to invoiced. And then when we are pending it, we're going to append it to a select. So our quotes and then I'm going to add the select select that has a name of action. So equal single quotes and I'll call this action. So what I'm going to do next is actually just duplicate this. After adding my semicolon, I'll just duplicate this because we need to do it. And then I'm going to add to action to save here. That will be the only change that we need to make in our code. One thing that I forgot to do here is actually just say the jQuery should kick off when our document is ready. So we have to add document dot ready. And then inside here we're going to add a function so that we know when our DOM is loaded, then we can run all the code that is actually in here. So I'll push this up. Otherwise, this code sort of runs without a jQuery having been initiated in our DOM. Have a little error here. So I'll quote this, then I'll change this here and then our function needs to have its parentheses. Then I'll save this. Okay. I'm missing a bunch of strings. So I need to cut this, add this here. Same thing for this since it's a same code. I'll copy and paste. Copy and paste since it's the same. Let's load up our console to see if we have any errors. I'll load console log here, reload this. So I'll look for the errors. Our error is not append. We have to append too. So you can see I made quite a mess with my jQuery or JavaScript, but we've made quite those corrections. So in our script we'll document, get jQuery. And when the document is ready, our DOM is ready. We'll add an option with a value marketing voice and a text change status to invoice. Then we shall append it to our select action, which is a, we'll add it to our select, which is here. That has an name of action. So what I'm going to do now is actually open up my console again, reload to see that we don't have any errors. So when we click the error, we actually see that we, when we look at our console, it was able to tell us that we have an extra bracket. So I'm going to go back to my console, reload. And now we have zero errors here. And what I'm going to do is I am just going to change all these actions that were failed. When I click now, I have changed status to invoice. And when I change them and click apply, we actually see that now they changed to invoice. So that's how we make those changes. That's how we are able to add our own statuses into our WooFamas. So feel free to try this out at home. Maybe make yours or that is talking about shipped or being shipped as an order status and let me know how that goes. So if you enjoyed the video, please give it a thumbs up or like it or leave a comment or just say, let me know what you would like us to work on. Thank you for watching and have a good day.