#29 LaraShop55 | Discount Coupons | Shopping cart Website development in Laravel 5.5 with Ajax

okay for coupon we will create a Ajax
function that will hit to your route then we will create our database table
that will check our coupon code is longer right okay make it ID textbox ID
and button ID for that go to your index file inside your cart folder
yeah here is a coupon that make it Xbox I be like is you can say coupon ID okay
coupon ID and for Butner you can say ID equal to Cooper billion that’s fine
and inside the your script here you will create a button click with button ID ven
dot clicks function if somebody click on this button and fill the data we will
get the data about over coupon ID and it will receive the value of your Xbox dot
value that’s simply a lot but we are getting okay save it opens your console
every time when you working on a Jack’s okay
reload fill something and you are getting it okay now a nice now we will
work on our rule network okay for network we will say let me expand it okay here we will come at this start a Ajax besides I guess just define your URL
default you error and inside this cat coupon okay you can name it anything
that’s not a matter and data I think we it only coupon code okay
coupon code s okay we will check from our database table here port equal to
plus sign for JavaScript variable coupon ID coupon I be something like this and
success function here response just a lot of bad spawns okay now we need
hydration CD application app I am gonna make that’s why HP dog CV my project
name is Lara short five okay here I will create PHP artisan hot pits and make
migration this a name is create coupons okay people the migration is complete
inside the database table yeah yeah migration folder last one I hope here we
will create one in PDF for discount in percentage second string for your code
okay here table spring for your coupon code okay cool one spending is Right
coupon code table this will be an Peter either for our discount that’s fine just
migrate PHP heartbeat son my great evil migrating go to PHP myadmin check ok
here is the coupon just insert the dummy value ABC X Y get okay discount will be
4% that’s okay now go here is your code now if I enter wrong coupon it will
alert wrong otherwise it will say apply that’s fine go to your success
no I need a now pass here on route new route for H yeah I am using at you can
use post of it Jack Cooper Cooper same name of function I will use inside our
controller okay let me check I have great aha
check out the controller here I will create the function M never function
request West as inside this return request all
data because I have – me here ok semicolon save it and say here you will
say check out controller name of your function that’s fine so it will be
returns your data something let me test
okay I have to reload enter anything it’s arigato okay that’s fine ah here
you would say you’re poor and we are getting code from px I will show you
here is code code equal to this I will check from my daughter is check
we will say BB BB table table name is coupons coupons where coupons for okay
coupons for the field name is coupon course it comes to your variable told
back it’s like if count off this variable
I mean it’s filled this means is bit one everything Oakley so we will check flight for now else you will check wrong
Cooper so our right right coupon ABC XY Jack he
lowed have anything okay I have a coupon score it’s not coupons
codes coupon code reload and try anything
click wrong coupon okay leave BC X twice yet applied everything is okay now here
where you are saying applied here you need one more table for use unused okay
for use which user use already that we will say you are ready used otherwise
you can use it for that create a new migration PA treat
our P son Mike make my greater age people name will be Jews Cooper yeah it
will be sensible for me make sense coupons table okay my christen complete
go to your last one migration yes we need only two and teacher people here
either one is people ID which we are tracking it okay second one second a
user ID okay that will also and Peter okay user ID who is using it okay that’s
fine PHP artisan migrate I think spelling mistake teacher be a
treat art piece and migrate okay it’s my greatest actually go to your PHP myadmin
check your new table used coupon in the last sake last okay here is a use coupon
now I will check here if if we have a user ID declare here Oh Heidi make sure
you have defined you be be a note okay now we will check where user ID this
coupon eye disease okay we will check from here used BB table evil name a new one
let me copy this I am so bad in spelling mistake it’s here where you will say
user ID which we already declared here so it’s very simple
and we’re coupon code coupon code I think let me structure and coupon ID
okay coupon ID with this coupon ID is it check check your variable which is
contain the whole data just add it index 0 and see this ID will check from there
if already head then we will say it is already just and here used equal to 0 this means this table is
empty so we can allow to use this apply coupon ok otherwise we will say get out
you only be jeweled bitch ok you already use this coupon safe I reload of browser
ok enter wrong coupon ABC X Y get its say apply a second name is only D say
apply this times you need to insert here and three this one okay so you have to
fill this coupon ID and you use a ready just insert lose come on okay here
because everything is going fine and your coupon applied successfully so we
will insert user ID in use the table use add here you I am very bad in naming you
can name it any variable you need few rules to coupon okay not here I think
here if is not using spin so we can say just use it and insert a new entry
insert you will say first it’s coupon ID okay second dish user ID so coupon ID
will be check or you can say code starting here okay
you can grab data from here you can hear here not a user ID save it
now if I try to apply and I have error okay
base table not found use coupons oh I am so sorry apply again XY jet is coupon ID
is not this one I have to insert I be a coupon numerical where care it’s int so
add applied and apply now we will get our data here as you can
so for now you can check your again this one you already use this coupon so
that’s very very school okay so in the next video we will try to achieve our
cart rotor we will modify this according to our discount okay so stay tuned if
helps you any facing any error please comment below thank you


Add a Comment

Your email address will not be published. Required fields are marked *