I have form that allows a visitor to purchase a item.
Under the price field I want to add a "Discount voucher" field.
I will create a table in my database that contains a list of vouchers with their corresponding discounts including a fields as to whether or note is has been used.
What I need is some pointers on how I go about showing the new price if a valid voucher is entered as well as some servers-side validation to ensure that the discount can't be illegally applied.
I presume that I could use JS to check the entry against the database and then display the new price if valid. Where do I do the server-side validation?
Under the price field I want to add a "Discount voucher" field.
I will create a table in my database that contains a list of vouchers with their corresponding discounts including a fields as to whether or note is has been used.
What I need is some pointers on how I go about showing the new price if a valid voucher is entered as well as some servers-side validation to ensure that the discount can't be illegally applied.
I presume that I could use JS to check the entry against the database and then display the new price if valid. Where do I do the server-side validation?
Thinking about it further... JS would not be the best approach. I would check onSumit and if valid then give the user the option of confirming purchase else return error if invalid.
Just need to workout how to code this now.
Just need to workout how to code this now.
Think that I have it sorted.
I have created my voucher table with fields, voucher code, value, expiry, date used.
I then used the DB record loader to check of the voucher exists ..... and so on
I have created my voucher table with fields, voucher code, value, expiry, date used.
I then used the DB record loader to check of the voucher exists ..... and so on
Hi abasel,
This is probably a case to use Ajax to check if the voucher exists and then JavaScript to update the calculation depending on the result. You should also double check with PHP after the form is submitted.
Bob
This is probably a case to use Ajax to check if the voucher exists and then JavaScript to update the calculation depending on the result. You should also double check with PHP after the form is submitted.
Bob
Hi abasel,
I'm currently confronted with similiar thoughts to your problem. What solution did you end up implementing if you don't mind me asking?
cheerio
Michael
I'm currently confronted with similiar thoughts to your problem. What solution did you end up implementing if you don't mind me asking?
cheerio
Michael
This topic is locked and no more replies can be posted.