 Welcome back to the channel. We're going to pick up from the previous video and see what this Ajax is doing once we trigger it from our food-add.js. When we trigger this post and send in the product ID and the variation and what actually happens when we come to our functions.php when we trigger this function and let's see what actually happens insert right here. If this is something you want to see then let's go into the video. So after doing that we're going to come back to our functions.php and we are going to be able to run the different things that we need to do inside our Ajax. So in order to see that we are getting the right product ID let's come here we're going to use a wp send json function and this function basically sends back a json response to our Ajax call that we are making. So what we're going to do here we're going to say if we want to get our product ID and we're going to say the product ID is actually going to equal to and we're going to use the post and this post is coming from our Ajax inside the type of post and we are passing this product ID and the variation ID to our techy food Ajax add to cut function right here and inside our post we're going to be able to just pick up the product ID because that's what we did the product underscore ID and after doing that we're going to copy this paste it in our wp send json let's see that we're getting this inside this function so i'll come back to our page so let's click on our barbecue pizza here i'll choose the small pepperoni i'll click add to cut you'll see that the form is submitted we also have the number 22 and when we go on a network you'll see that we had a post of 200 to our Ajax which is good and then when we click on the request here you will see that we have a product ID of 22 and we have a variation of 24 that was passed and you can see right here we have an action which is coming from our javascript with the product ID and the variation all going inside Ajax so this shows us what is actually going on we have a proper Ajax loading and inside our code we have everything going on very well and in here instead of just having the product ID i want us to get also the variation we are also going to get a quantity so let's first get the variation i'll say variation underscore ID and then here we shall also get the quantity and we're going to say the quantity for now is just going to equal to one now you realize whatever we're picking from this post should be made into an action number so that we don't have errors so what i'm going to do is i'm going to wrap an abs int on this to say that this needs to be an integer absolutely so i'll copy this right here paste it right here so that we have this working actually very well now if we want to be able to change the quantity instead of it being one here we shall see that in a future video where i'm going to add a little box here to allow us to have different quantities but for now we're going to leave it at one so that we can be able to just get one item and add it into our cut so under here the next thing that we shall do is we're going to have an if condition that will allow us to run our code and the first thing we want to do right here is we want to say so if we come us and we're going to look for the method of cut and on cut we're going to look for add to underscore cut we're going to look for that method and we want to say we want to pass the product ID we want to pass the variation ID so we pass the product ID add a comma get the variation ID as well add it in there and we're also going to get the quantity and this quantity always comes before the variation ID and what we want to do inside here if we have all these items added to cut we should be able to do an action so we're going to do a do action and the do action we want to do is we want to say who come us Ajax added to cut so we'll say who come us Ajax added to cut and that's something we want to do and then after doing that we want to be able to get this product ID so I'll copy this and I'm going to pass this product ID add a semicolon right here and we're going to come down here and say if so we're going to check if yes is equal to we're going to get an option and we're going to check do we have the who come us cut redirect after add we're going to check for this option if it's set in our database and this setting won't be found by going to the dashboard and inside our dashboard we'll go to who come us and we'll go to the settings of who come us and then we'll go to the products area where we can always stick for the cut behavior to be to redirect to the cut page after successful addition so I'll click this to save and that means we shall be able to access that particular setting from our database inside the options and then what we're going to do is we're actually going to come and say we're going to use the who come us add to cut underscore message and inside that we're going to pass an array of information and the array we want to pass in is the product ID and we're going to onto that product ID we're also going to add the quantity so after doing that we need to be able to say this is true we should pass the message and say this is true so right now after doing this we've had our if statement if that is correct else if that doesn't work out then what we are going to do is we're going to pass back some data so we'll say the data is actually going to equal to an array and inside that array we're going to just have an error we're going to say our error is actually true and we just need to wrap this in single cuts because it's going to be part of our data our data array and then we're going to pass in the product URL so we'll say product underscore URL we're going to get the pama link or like the link of that post and inside this we just need to add the product ID so product underscore ID that's what we need to pass we shall then echo RWP send JSON after that error and we're going to say let's echo that so that we can see whatever is going on and we should just be able to get this data right here so I'll pass this data here save this make some cleanups right here and I am going to come and reload my page we'll clear our mini cut let's go to pizza we're going to hit margarita pizza here we'll choose one large paparoni click add to cut that gives us a success if we reload this here we should be able to have our margarita paparoni right here just one of them let's try to do it with barbecue steak pizza let's choose two small extra cheese let's also have the large olives click add to cut we have two successes right there I'll reload this and you're going to see that we have our steak pizza showing the extra cheese we have the paparoni we'll try again margarita pizza let's now go for a small paparoni and olives click add to cut we have one success showing up here we actually have two successes we should be now having a number of items in our mini cut and you see we have the small paparoni and we only have three pieces in our cut so something is broken but we are doing something right so I'll clear this item save this let's look at our network again I'll just go to pizza I'm going to click margarita I'll choose three of the large items click add to cut you'll see we have all our edges actually showing up doing everything right when I reload this page you see we only have two items showing up right here so we need to find out why this is a big problem and we shall be able to do that in the next video if you enjoy this video don't forget to give it a thumbs up don't forget to share it with your friend give it a like and let me know in the comments what you're using these tutorials to actually build something for yourself let me know what that project is and enjoy yourself