Jump to content


Photo

Coupon Code System


  • Please log in to reply
1 reply to this topic

#1 ImJustBrndn

ImJustBrndn
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 24 August 2006 - 02:05 AM

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 field
Where to store the coupon codes
Suggested methods

Any information would be greatly appreciated thanks.

B

#2 drkstr

drkstr
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationSeattle, WA - USA

Posted 24 August 2006 - 06:01 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users