 Have you ever picked code from a website and they say get this code, add it into your website and then eventually you're going to have it showing up and doing this particular thing that you've always wanted to do. Well in today's video I'm going to show you how you can actually do this. So first and foremost we have a little bit of code here that allows us to have a flat rate of five dollars and then we get the taxable amount and then we throw it on a WooKama card and add an extra fee or a VAT charge which is a value added tax into the system and eventually you get a total of this. How did I get this to work? There are two ways of actually doing this. The first one is if you get this code here I'm going to copy it and then I'm going to just comment it out and let me reload this and you'll see right now we don't have any of that code working here so we don't have that function in our website. Two ways. The first way is that you go into your WordPress install and inside your WordPress install you'll see this number of files and when you go into the wp content file you have about four different files, four folders, give or take. Now inside this we have two files that would be particularly interested in. We have the plugins file and we have the themes file. Option number one that you have here is to add to the themes file. So inside the themes you go inside the themes and I don't know how many themes you have installed maybe one but inside my own install if I go to the appearances panel we have themes here and I will notice that my theme that is installed is actually 2019. How do I know this has no activate button but when I hover over this we have activate. So this is my theme that is actually active. Now I'll go inside 2019 in this case and I'll look for a file called functions.php and when I open it all I need to do is go all the way to the bottom add a themes of empty space then I will paste our code that we had actually picked from the other side. If I save this and come back to our page and reload it we'll see that we now have our vat actually working here. So if I decided to change this vat and record it maybe surcharge and save you'll see you on the reload here that we actually have our surcharge actually showing up here and the function is doing well. That's step number one. Now step number two of actually adding your code properly into your WordPress is using a plugin but first let's remove this code here so that we have everything as fresh as it was before. So function not showing up here. Now for this to actually work very well you actually have to go inside back into your WordPress install go to wp content and then you're going to your plugins folder. Now inside your plugins folder you'll open up a new folder called for example I'll call it takey press add prices and then inside this I will create a new file but what I'm going to do is I'm going to use a code editor. If you don't have a code editor you can use notepad in here and then inside notepad you'll add a few lines of code and then save that file as php but if you have a visual editor like I have here in the background which is called visual studio code all I need to do is actually just drop this file in there and when I drop it in here you will see that it is empty all I need to do is create a new file and then call it takey press who add prices like we had our file here but instead of just stopping there we add an extra full stop and then we'll call it dot php because WordPress actually runs on a server side language called php so that's where all the code is actually got. Now we'll add our code inside our php file but before we do that we open up with php tags to show that this is a php file and then we'll paste in our code let me increase the space here we'll paste in our code and save however this is not yet ready to work because the way WordPress recognizes plugins is by having a number of lines before all this code but you only need to do it once you don't do it every other time so I start off with two slashes and inside those slashes I'm going to add some lines some stars in there to show that this is a comment block we call this a comment block and in this copy block the first thing we need is actually to have a plugin name now this plugin name will allow us that when we go inside our plugins in our WordPress you will be able to see this particular plugin that we do have so I'm going to call this plugin taking press add prices and when I save this and reload here you will now see that this is recognized as a plugin and I can actually click activate then when I activate and come back here and reload this this will actually work so it's vat with that because we have vat here but if I wanted to call it a soda price for example and reload here you'll see that it is soda price with the extra calculation or getting a flat rate of five and then multiplying this cut fig with 18 percent and then just adding them together to give us that new soda price so this is how we add things in a plugin but you'll see that my plugin is different from all these others it's because there's some extra lines of code that are actually missing here so on the next line if we press enter we need to add what we call the author and the author will be taking press in this particular case and if I save this come back here and reload this I want you to note as you make these changes they don't break any of your code so if you come back here and reload you'll see that your function is still doing well but you will see that now we have by take a press but it's not blue as this other one and it doesn't have a link it's because we've not added the link for the author so we're going to add a plugin link and an author link here so we'll enter here and then we'll say plugin URI so the plugin universal identifier is got here so we'll add a link this link to my blog and I'll have it as the plugin URI if I save this reload here you'll see that we now have visit the plugin site and it's linkable so I'll duplicate this and instead here we shall say author URI and when we save this you'll see that we have take a press actually showing up here now the other thing that we need to add is this small description that's showing up here all we need to do is add a description and we'll say this plugin adds extra fees to WooCommerce or you can say this plugin adds all my functionality that I pick from outer space or wherever it is and then I add it here so when we save this come back here and reload you'll see that we actually have this showing up here now that's all you need to have your plugin active that's all you need to add more functions to your particular website and so on so if you get tired of actually the particular function all you need to do is come back deactivate this and when you come back to your page you'll see that you no longer have the solar price so that's how you do it I would encourage you to open up a different plugin for the different functionalities because of this simple turn on and off switch that you have here in contrast to you actually using something like the functions .php because what happens when I use my functions .php file and then I change the theme let's try that so we'll go back for our wp content go to our themes 2019 we had our functions .php here let's go all the way to the bottom I'm just going to copy this code here and then paste it in our functions I'll make some changes here so that you can see that this is actually coming in from the functions .php so if I reload here you'll see that we have solder and the price is increased in comparison to before now if I change my theme if I go to themes here and then I change to another theme let's say 2017 and activate it if I reload this you'll actually see that we lose our function here because it's not in the functions .php of the the current thing that you're working so that's the disadvantage of having this code inside your functions .php but if you had it in the plugin so we'll go back to our plugins installed if the plugin was active and you reload you'll see that you will have your solder price showing up here and even if I went back to the themes and changed inside another theme let's say I reactivated my 2019 and then reloaded you'll actually see that we have our solder price showing up here so that's why I would advise you to actually use a plugin in contrast to having your code inside your php functions file so thank you for watching this video if you enjoyed it if you got some new material for yourself please share it with your friends like the video and then don't forget to subscribe