ImJustBrndn Posted August 24, 2006 Share Posted August 24, 2006 I have a fully functioning shopping cart script now thanks to the help of this forum, but I'm wanting to add a coupon code box. Could someone tell me how to implement this. My cart products are stored in a session and only the ids, name, and price are stored in the database. Could someone please walk me through and give me a good starting point on:Adding a coupon code fieldWhere to store the coupon codesSuggested methodsAny information would be greatly appreciated thanks.B Quote Link to comment Share on other sites More sharing options...
drkstr Posted August 24, 2006 Share Posted August 24, 2006 Well it's impossible to say what would work best for you without knowing how the rest of the code is implemented, but here is what I would do.add on to your product object or derive a new one as a child of the product object. The constructor (or a some method) would take the cupon code as a parameter and use it in a switch case to pick a memory reference to the apropriate function that "discounts" the itmes (unless you will only be discounting in one way instead of beig specific the the coupon). Each of you products would check to see if a cupon code is defined, and if so, parse it through to see if it can discount itself, and if so, what discount it should apply. You might want to also keep a database of coupon codes which lists each product ID it would apply to. The object would check to see if it finds itself in this list before discounting it's price.regards,...drkstr Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.