 Na kwawe ni chabu, kwawe ni maikama kumuPhone nukicsin wa kama Kuma nameyita k garmenti na kutonde kama u teacher, wa kwawe dokata kusimisha na na kutuna k Spider Nabuki napa kwawe jenida, na kutua ya kuwa naka kwawe conta kwawe nisha kumindikunia kutunia kumu kawe k remember Should it be the XCEMT from VAT Or if you want to use this as a gift shop And you want people to say I would like an extra wrapping On my gift please wrap it for me and just deliver it and then an extra fee would probably show up at the end here So, if this is something you're interested in let's continue with the video I will leave the code for you in the description You can also be able to print that up wa nusit inwebsite o follow along with that video. So, let's dive in. Now, the first thing we're going to do is create a button right here for us that will allow us to do this exact kind of thing. So, the first thing that we do is add an action and this action is going to tap into wukamas and we're going to use a hook kama after check out billing form. And basically it's going for checking out after the billing form and the billing form is this particular section that we have here that has all the billing details that are actually needed. So, we'll use the wukamas after check out billing form hook and then we'll chain on our own kind of function and I'll call this techie press add vat cancel button. And that's the function we'll use. We'll copy this and some space below and then start writing our function with the name and then write our code in here. Now, the first thing we'll do is we'll add our own HTML since this is outside of the usual billing form. We'll add our own HTML so we'll echo and then we'll add a div tag inside here. So, we'll do a div with an ID of vat cancel. Close this off, the semicolon and then I'll duplicate this so that I am able to close off this div and then take this away. Now, after adding our HTML we go into the PHP and we're going to look for the wukamas form fields. Now, inside the wukamas form field we're going to add a number of arguments that will allow for us to have this particular form on our front end. Before I do that, let me save this and see what we have on our front end. We still don't have that field showing up and that's why we need this particular code. So, I'm going to uncomment this out and then we'll start by adding the ID techie press vat cancel and that will be the ID of our field and the next thing that we need to do is describe what our field will look like by providing this array of information and then after that we shall tell wukamas to actually get the information from this field and then feed it anywhere. And the way we do that is by using the checkout and this checkout variable actually comes from the hook that we are currently using the action that we have here. It's available for us to use inside our particular function, which is this. So, we'll have this checkout and it has a method on it which is called get value and the value that you're going to get is actually this particular ID. After getting that, all I'm going to do now is just add the array that will show the information that we're going to show in the front end. So, the first thing that we need is a label that will tell us what's going to happen. So, here we're going to say I am vat exempt which will allow people to just tick so that they know I'm vat exempt and then the calculation is not done. And then what we need to add is we need to add a class so that we can style this if we ever want to style it differently. And this takes in an array and inside here we can pass in the wukamas common fields or we can pass in our own information. So, I'll just call this vat cancel. Should I need to add any extra styling so vat cancel button and then after adding the CSS, I need to add the type of field that it's going to be. Checkbox and this is all available for us in wukamas. They've made a form API of some sort that we can tap in so we have the type of checkbox right there. Now, if I save this and then come and reload on the front end, you will see that we now have this box here which actually does nothing and so we are ready to now use it to do the difference and calculations that are used here. So the first thing that we do is actually trigger Ajax because we want to be able to do this when you check this you automatically the customer gets the calculation done. Otherwise this becomes very static and it's not interactive. So we tap into Ajax which is used by wukamas so I'm going to inspect this. So right now when I check this you can't see anything going on but once I tap into the wukamas you're going to be able to see that every time we tick it we trigger off a function of wukamas to update the particular cut and update the information that's going on here. So how do we do that? We do that by using JavaScript so we're going to use an add action that taps inside WordPress to use the WP footer hook. So we have our add action and so we're going to use the WP footer and this is going to require us to pass in our own function and I'm going to copy this and then I'll just say take a press VAT cancel Ajax. So that will help us to make it unique and so we start writing our function here and then the first thing that we shall do at this particular moment of starting our Ajax is we're going to write some JavaScript so we need to escape the PHP and then we need to open it up again and then we can have our script here and then of course this will be a type of JavaScript so it will be text stroke JavaScript and so all our JavaScript will actually go inside here but before we do that we can add some performance uplift by saying we are going to check if this is actually on the checkout page then we run this particular script if it's not then we ignore it so we'll say if is checkout so if we are on the checkout page then we shall run this particular PHP so I can do this and then also close this so if we are not on the checkout page this particular JavaScript will not run so that's how you improve some performance by doing very little things like those now let's go to the JavaScript now inside the JavaScript we are going to use JQuery so we start off with our JQuery we are looking for documents when the document is ready that's the event we are going to look for so when it's ready then we shall run our script that we do have so when it is ready we are going to run a function and what does this function do this function is going to be checking for a particular ID so we run in here and say we are looking for the ID and we first of all bring in the pound sign to say what are we looking for we are looking for the ID of this field and what we are going to do is say when we get this clicked so when this is clicked then we are going to run another function in here so the function that we run when this is clicked is this so the function that we will do is again use our JQuery and then search for the body inside our body of our document we are going to trigger a wukamas function which is actually called Update Checkout so we look for Update Checkout so now that our JavaScript is actually done let's save this and then let's go to our front end and I want to show you how this works out inside our JavaScript and inside our console so of course now we see that we don't have any issues but now we can see that we have a new order review that is available for us in here so every time I take this I'll get the order reviewed if I uncheck it the order is reviewed check it, review uncheck it is reviewed now what happens in the review here if you look at the Request tab and you will see that we have a Wordpress Nones for security we have post data here that is tracking all this information and sending it inside our Ajax for example the first name, the last name, the phone number the billing email, order comments but we don't have this data for this particular piece going inside the post data and that's what we are going to tap by the next code that we are going to add in to make sure that our post data can receive that information and then we can use it to update our checkout so what do we do? we go for more PHP how do we want to work this out? we want to use this WooCom as calculate fees and that's when we want to have that particular action being triggered so that when we tick then we can calculate the fee inside our update and how do we do that? first things first we are going to check if we have anything actually being posted from our phone and we are going to check if we are using Ajax and we are not in the admin area so we are going to say if there is no post or we are not doing any of these two things so if we are in the admin then you ignore so we use the ease admin function if we are in the admin ignore and if we are not using Ajax if we are not using Ajax then also we need to ignore and how do we say ignore we just return so if we are using Ajax and we are posting information then the rest of this code can run the next thing we are going to do is we are going to check if we have post data which we saw here and we are going to try to chain on the post data that we do have so we are going to come back here and say if is set so we are going to check if is set if we have post and inside this is all javascript if we have post data so we are now working within the Ajax and looking for that object if we have that then we are going to chain on our new posted data from our phone and if we don't have that set if we don't have this available then we are going to fall back to the non Ajax way we will say post data is actually equal to what we are now posting currently so this is the fall back position but if we have Ajax and we have this post data available what we are going to do is we are going to pass it as a string so we use the method of plus str string which is php and what are we going to pass in here for argument we are going to get our post data and then we are going to chain it onto the post data that is available so we are getting what is being posted currently with this and then we are going to chain it on the existing post data that is passed on into the Ajax so once we finish getting our variable post data the next thing that we are going to do is check if we have passed in the data from our check box here so that's the next path we are going to do so say if is set we are checking to see so we are going to check in in our post data object we actually have our take-a-press vat cancel so we are going to check do we have this canceling information inside the post and if we do then we shall run our code of actually adding a custom fee so the first thing that I need to do is I am going to do some code refactor to make sure that some things go way above and beyond so what I am going to do is cut this and bring them before here the global wukamas can always be up there and then we are getting the flat fee from inside our admin area in the settings we are getting the particular percentage so if I check in my dashboard and then go to wukamas and then go to settings we'll be able to see in vat pricing where we set our flat fee and our dynamic fee of wukamas so if I change this to maybe 0.1 which means 10% of the tax and I came back and reloaded here you see that this value is actually going to go below what it was before now back to what we were doing so we are able to get our flat fee and dynamic fee so this is not broken that's a good thing and next we are going to say we don't need flat fee is equal to flat fee so I will check remove this this code is checking for this field and getting to know whether it is ticked or not if it is ticked then it's going to say please ignore the vat so what we are going to do at this point is just return meaning we will not do any calculations but if this is unchecked then we shall be forced to calculate this fee that we have here and save it so let me save this come back here reload and I want you to check whenever we tick this we are getting an order review and our fee is actually going out when we un-tick it we see that the vat comes back and inside our request here just look at the post data and you will see currently we don't have anything to do with take a press but when I check this out we just need to look at the next request and you will see that we have take a press vat cancel is equal to one in here so that's what we are looking for here and saying if we have set take a press data and it is actually true or it is equal to one then we don't do anything but if it is equal to zero or if it is nonexistent then we do that calculation in here so you can always set this post data equal to zero so that if it is zero don't do anything if it is one then do something you can set this to false or to zero it would actually work out well so that's how we would make it possible to check this and check out so you can use this on your gift shop to allow people to have wrappers ordered and then you can add an extra fee for packaging so if you enjoyed this video please share it with friends don't keep it to yourself like it leave a comment if you're struggling with something ask a question and since it's a new month I'm doing new content for the month so you can leave in the comment what you would like to see on the channel otherwise enjoy your day