Jump to content

Coupon Code System


ImJustBrndn

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.