Im doing a form where you can fill in personal information and select products. It dynamically adjusts the prices with some simple java scripts and eventually puts out all the information in a PDF file.
Now I have to implement a bonus code. Like when you put in “BONUS2011” you get 20% on all selected products. It has to by dynamic. Like the moment you correctly fill in the bonus field you get the 20% on the prices.
My question is now what is the easiest and most simpliest way to do this? I could just store the bonus code in the .js but thats of course not an ideal solution. My knowledge in Javascript and PHP is very limited (as you mightve noticed).
Thanks in advance!
Since you have no code snippet, I’m going to do a very rough example of what you can do. Just make sure that the information you use to charge the customer is calculated correctly after s/he posts and that you don’t rely on a
Totalfield from the form to determine what to charge them (since that can be manipulated when it’s posted).Do not put the bonus code in the JavaScript as everyone will be able to view it.
Rather implement an AJAX call to update the price field. There are plenty of examples out there. It’s also easier if you use a JavaScript library like jQuery (http://www.jquery.com).
With jQuery it’s really easy: