Opinions: Discount Voucher

abasel 04 Feb, 2013
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?
abasel 04 Feb, 2013
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.
abasel 05 Feb, 2013
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
GreyHead 05 Feb, 2013
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
swd 15 Apr, 2013
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
abasel 15 Apr, 2013
Hi, alas I dumped the concept as I simply could not get it to work... well to be more correct, I got it to work but not securely.

What I plan to do is to see if I can commission someone to do it for me; but that is a task for a later date :-)
This topic is locked and no more replies can be posted.