Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > One Time Use Discount Coupons View modes: 
User avatar
Member
Member
cmao-usfi - 2/21/2012 10:44:38 AM
   
One Time Use Discount Coupons
Can you tell me if there is already a thread on this subject or help me try to solve my problem. What I would like to do is create coupon codes that can be assigned to a customer. Once that code is used, it is no longer valid. Any example code would be helpful. Thanks.

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 2/21/2012 1:44:47 PM
   
RE:One Time Use Discount Coupons
I may be wrong, but I believe that you will need to create quite a bit of custom code to make this work.

I think that the way that would be easiest, but not completely fool proof would be to create a table that stores a UserID and CouponID and any other data that you may find pertinent. When a user uses a coupon code, check this table to see if they've already used it. If they haven't used it yet, allow the discount to be applied and insert an entry into that table so that they can't use it again. I don't know enough about the e-commerce system in Kentico to tell you how to validate the coupon code for the user, so you're on your own there. This method would allow the user to create another account and use that coupon again, which makes it less fool proof, but it could be unlikely that the user figures this out.

Another method would be to create a table that stores a new generated coupon code,a CouponID for the real coupon that it refers to, and a bit field to indicate whether or not the code has been redeemed as well as the date it was redeemed. The user enters in the generated coupon code and you add some code to check the database to see if that code has been redeemed. If it hasn't, look up the real coupon and apply the discount.

I hope this helps at least a little bit.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 3/15/2012 9:35:27 PM
   
RE:One Time Use Discount Coupons
Hi,

More customers are asking for this feature and it's possible it will be included in the next version (7.0), however it's reasonable to implement it as a customization in current version. We are collecting some tips to provide guidelines for its implementation.

In short, there are two main ways, either to add a binding custom table (simpler or more complex) as suggested by Jiveabilion (Thanks for your post!) and check the coupon validity in appropriate controls with your code,
or you could also add a code to ProcessStep method in the ShoppingCartPreview control code, and after the order is created (and it contains a coupon that's one-time-use .. guessed e.g. from a coupon code pattern) you could set the coupon's property ValidTo to the current time, so it can't be used any longer and you will also have a track about when it was applied. All those actions should be possible by DiscountCouponInfoProvider.
More details in API reference

Regards,
Zdenek