in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Single use coupon.

Last post 10-03-2008 8:19 AM by Mattias. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-19-2008 2:52 AM

    Single use coupon.

    I'm having problems with this coupon option. What have I do for delete a coupon when is it used?

     

    Filed under:
  • 09-26-2008 8:30 AM In reply to

    Re: Single use coupon.

     I was wondering the exact same thing. Currently I am able to use a coupon over and over, regardless of it's single-use status. But my site (at least the frontend) is heavily customized, so it's possible I've accidentally removed the code that does that.

  • 10-02-2008 10:23 AM In reply to

    Re: Single use coupon.

    Answer

     I managed to solve this.

     

    I added the following code to the process order button:

     if (!string.IsNullOrEmpty(txtCouponCode.Text))
                {

                    CouponCollection couponCollection = new CouponController().FetchAll();

                    int couponId = 0;

                    foreach (Coupon coupon in couponCollection)
                    {
                        if (coupon.CouponCode.ToString() == txtCouponCode.Text)
                        {
                            if (coupon.IsSingleUse == true)
                            {
                                couponId = coupon.CouponId;
                                Coupon.Delete(couponId);
                            }
                        }
                    }
                }

     

    (might need some modification, I've removed all the ajax on the checkout page in the store I'm working on. Specifically, the txtCouponCode.Text might need to be referenced differently)

  • 10-03-2008 7:56 AM In reply to

    Re: Single use coupon.

    Normal 0 21 false false false ES X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

     Thanks for your code. It runs fine but it has a problem:
    1º An user introduce his coupon and obtains his discount.
    2º He cancel the checkout process before complete the payment because he haven’t payment information at this moment.
    3º One hour later he try to complete the payment, but HIS COUPON DOESN’T RUN Super Angry.

    I think it’s better create a table for register coupon uses. If an user try use the coupon in the same order it will run, but if it’s another order it will break.

  • 10-03-2008 8:19 AM In reply to

    Re: Single use coupon.

    Yeah, I am aware of that problem.  And you're right, not the most elegant solution. I mostly just wanted to show the delete code, then it's easy enough to work out the kinks afterwards.

     (I just don't think it's needed to have the coupons stay in the system after they're used if they are single use. Preferences may vary)

Page 1 of 1 (5 items)