 Welcome back to the channel. In today's video, I'm going to answer a question that many of us do have, and that is, how can we get shipping zones to expand beyond just the state level, and what do I mean? When you come to Wukamas and you choose your country, it assumes that you only go one level deep in terms of the geography, for example, I'm living in Uganda and it assumes that you only have the district level to go by. What do I mean? If I open up the map of Uganda, it looks like this, and if I choose one city or one state or one province in whatever demarcation your local area is in, you Kampala is a district, and when you go into that district, you sort of get to see that it has more divisions. So you have things like Machindia, Okawempe, Onakawa, and these are really huge in terms of distance. So if I want to use my shipping zones and determine the prices of these areas, it cannot be the same fee. What do I mean? When I come back to the settings here and I go to the shipping, I should be able to create a shipping zone that goes beyond just having Kampala itself. I need to be able to go a level deep down to about Nakawa, Machindia, Okawempe. So that's what I'm going to try to do. I'm going to take this into three levels deep. So if this is something you're interested in seeing, then let's dive into the code. So in my WordPress website, I'm going to go into the WP content, I'll go into the plugins, and I'm going to create a new folder which I'm going to call three level states for wukamas. So I'll copy this and I'm going to drag this and open it up in my editor. So I'll add it to the level. And I'm going to create a new file which I'll call three level states wukamas.php. And in here is where I'll start writing my plugin. I'll use my sleep edge to start my plugin so that I can know what I need to do. So I'll call these three level states for wukamas. And then I'll go and change the author link. So I'll give this my URL for my blog and I'll add in my name. Then I'll say add shipping zones three levels deep for wukamas. Right, the version will be that I'll just allow my license to go to gpl2. And then I'll just do three lsw for my talks domain. So that should probably be able to help it. So I'm just going to save this. Then I'll begin by putting some little security. So look for the defined and I'm going to look for one particular global. And that is abspath. So if anyone tries to access my plugin directly, not using the default WordPress way, they're going to end up getting nothing in return. So that's what this line is for. So I'll just say add basic plugin security. I'll save this. Now the next thing that I'm going to do is use a filter because that's the way we tap into wukamas states. And we use the hook, which is wukamas states. And then after that, I'm going to add my function, which I'll call techie press three levels deep states. I'll copy this. And then I'll begin writing my function right here. And I'm now ready. Now this filter gives us the states argument which we can use here and always first return these states so that in case you mess up anything or you forget to add the states, it's always going to run and you won't have wukamas shouting at you that it has an error. So if I save this, come back to my wukamas. I'll just close off these maps, reload this. If I come back and look for Uganda, I still have it at district levels. Now, in order for us to influence what's happening here, we need to get our states. And in the states, I'm going to look for the UG. And inside that, I'm going to have an array that I want to pass in. So inside this state, I am supposed to pass in first of all an ID. So I'll give it a 1999 just to make it unique. And then I am going to add a name and I'll say maybe let's go for techie press. I'm going to duplicate this and make this two. Then I'll say techie press two here. So I'm going to save this. Come back into my wukamas. I'll reload here. I'm going to go into my plugins. And then I'll activate my three level states. I'll reload here. And you'll see that when I go to Uganda now, I have techie press and I have Uganda. Techie press, techie press two and all those are my states in Uganda. Now this is sort of a hack that I'm going to do, but it doesn't break anything that you have. It would just help you basically level up a little bit easier. So what I'm going to do here is I'm going to create a new variable, which I'll call map. I'm going to make map an array. And what we're going to do with map is that we're going to now add some cities. We're going to say cities is equal to an array. And we shall say, we're now going to mirror what we have here. So I'm going to copy this right here, put it in here. And then I'm going to say, whenever I come to the individual cities, I want to add more data. So I'm going to have an array and take this a level deeper. So we're going to have an array here and we're going to say this is the city name. So this will be city. I'll map this as the city. So our city will be techie press. And then I'm going to break it down into a sub level, which I'll call a division, for example. And then inside that, I'm going to have a division, which I'll call Nakawa. So I'll change this techie press into Kampala so that I remain on point with what's going on in my own country. I'll change that to Kampala. So we have the city of Kampala. It's broken down into Nakawa. And I'm going to do the same thing here. So I'm going to copy this array here. And then pass this down here. So we have our second city division. And we're having the city of Kampala and we're going to break this down into Machindia. So I have these two. I don't know why this is screaming at me. Okay. So now I have two divisions of my district, which is Kampala. So what I'm going to do here is I'm going to do it for each statement. I'm going to say for each of the cities, so for each of the cities as city. And on this city, I'm going to map on its city value. So I'll map on the city value. I'm basically saying let me get this city and then I'll get this value right here. So for each one of the cities, I'm going to get our map that we have here and I'm going to map on the different individual elements here. So I'll get our map and inside the map I'm going to get the city, which is going to give us just this number. So I'll get city here, pass it in here. And I'm going to say each city is going to equal to the city value and for the city value I'm going to get this city right here. So I'll copy this, add it in here. So I'm going to chain on something else. I'll copy this, paste it here and what we want to do is also chain on our division. So I'll terminate this and in order to chain this I need to use these two dots and then I'm going to put a comma and that will be my separator for now. For example, I'll have ug2999 is equal to the city of Kampala, Machindia as my division. Now after getting this map I'm going to copy our map here and I'm going to change our stats.ug into map. It's basically just replacing what we had here and it's just going to get the city value. So it's going to get Kampala comma Nakawa in place of Techiepress. So let me just replace that map here. I'll save this. Now let's go back into our Wukamas reload. And now let's say we want to make a shipping zone called Nakawa. I'm going to come here and I'll look for Nakawa and you'll see that I have Kampala, Nakawa, Uganda. And I'm able to give that a flat rate of let's say I'll get the flat rate and I'll say every time I want to ship Nakawa it's going to be $30. I'll save this. I'll save this. And then I'm going to come back to the shipping zones and I'm going to create a new shipping zone for Machindia. When I come here to Machindia you're going to see that it shows up. We'll give it a method. We'll say it's also a flat rate and in our flat rate we're going to make that $40. Maybe Machindia is a little bit far off so it needs to be a little more expensive. So I'll save that. Now when we come to our shipping area so I'll restrict my countries that I ship to and I'll say that's going to be to a specific country. I'll add it to Uganda and I'm going to hit save here. So I'll come back to my shop I'll add this to the cuts I'll view the cuts I'll go to proceed to check out right here and this will fill in my details that I need to have and when I fill in my village here so when I choose a district you're going to see now it gives me Kampala Nakawa or Machindia and if I choose one you'll see that Kampala Nakawa is going to give me $30 or if I change it to Machindia we're going to have $40. It brilliantly works out for me in the event that I want to have so many levels deep and I can restrict them and give them different fees. That's the best way of doing it. That's the hack that I see that would be so easy for you to do but you can think of different ways. You can decide to split even this and fill it in any other field that you have on your checkout page. If you like the video please give it a thumbs up checkout the description for any other things and if you want to know about the channel or the video thank you and bye-bye.