Hello,
I've seen several posts throughout the forums asking for a way to allow customers to come to an AC7 website and make a purchase without having previously shopped on the website. The only requirement for this would be to allow the creation of a coupon that does not need the customer to be in a group since by default new customers are not part of any group when they create their account. However, I have not seen an answer to any of these requests with a working solution.
Here's a practical example of what we need:
We advertise in on the web, in magazines, on postcards & flyers, and on posters. Many of our advertisements have coupon codes for potential customers to use which offer them 10% off of purchases in specific categories. For example, we just advertised for 1 month on MySpace.com offering 10% off of all CD Duplication orders by using one of our coupon codes during checkout. This ad was seen by upwards of 500,000 people. Now, when people come to our website they cannot use the coupon because they have not previously purchased from us and are not part of a "group". We are now forced to manually add them to a "customers" group after explaining to all of them that they must first setup an account and then email us with the address they used to sign up for the account. This is a very, very tedious process and will take far to much time to continue each and every month that we offer these discount codes. The idea here is to invite new business with the discount code and make it seamless for them to make their purchase. I can tell you from several years with another ecommerce solution that this is a HUGE drawback to the current coupon system.
So, how can we setup a coupon so that anyone, without being part of a group, can use our coupon codes to receive their discount.
Next, is there a way to keep certain groups from being allowed to use these "non-group" coupons? We have some customers that receive 10% or 15% off of all items and we do not want to allow them to use the additional coupon codes.
Thanks for your help!
Coupon for first-time buyers
-
- Lieutenant Commander (LCDR)
- Posts: 91
- Joined: Mon Sep 22, 2008 8:37 pm
- Location: Northeast Ohio
- Contact:
Re: Coupon for first-time buyers
First you can create a discount for order with desired discount amount and can be used only once by a customer. Then you need to do following things
1- Send an Email to people with a link to your website page with encoded coupon code. In order to automate this process you may create some Email template and then write some code to send Email manually to people. Reading following thread will help you
viewtopic.php?f=47&t=8575
2- Now edit your Global.asax file and add following method to it
After this mod you application will look for coupon code in URL against each request and will store it in session if found.
3- Now edit OnePageCheckout.ascx.cs file and add following method to it
This function will help you apply coupon through code
4)- Now locate following code in CheckingOut(object sender, CheckingOutEventArgs e) method
and make it look like
this mod will automatically apply any coupon found in session when user tires to checkout.
1- Send an Email to people with a link to your website page with encoded coupon code. In order to automate this process you may create some Email template and then write some code to send Email manually to people. Reading following thread will help you
viewtopic.php?f=47&t=8575
2- Now edit your Global.asax file and add following method to it
Code: Select all
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
string couponCode = Request.QueryString["CouponCode"];
if(!string.IsNullOrEmpty(couponCode))
Session["CouponCode"] = couponCode;
}
3- Now edit OnePageCheckout.ascx.cs file and add following method to it
Code: Select all
private void ApplyCoupon(string couponCode)
{
if (String.IsNullOrEmpty(couponCode))
return;
Coupon coupon = CouponDataSource.LoadForCouponCode(couponCode);
String couponValidityMessage = String.Empty;
if (coupon != null)
{
if (!CouponCalculator.IsCouponAlreadyUsed(Token.Instance.User.Basket, coupon))
{
if (CouponCalculator.IsCouponValid(Token.Instance.User.Basket, coupon, out couponValidityMessage))
{
Basket basket = Token.Instance.User.Basket;
BasketCoupon recentCoupon = new BasketCoupon(Token.Instance.UserId, coupon.CouponId);
basket.BasketCoupons.Add(recentCoupon);
// APPLY COUPON COMBINE RULE
//THE RULE:
//If most recently applied coupon is marked "do not combine", then all previously
//entered coupons must be removed from basket.
//If most recently applied coupon is marked "combine", then remove any applied
//coupon that is marked "do not combine". (Logically, in this instance there
//could be at most one other coupon of this type...)
string previousCouponsRemoved = "";
if (recentCoupon.Coupon.AllowCombine)
{
//IF ALLOW COMBINE, REMOVE ALL PREVIOUS NOCOMBINE COUPONS
for (int i = (basket.BasketCoupons.Count - 1); i >= 0; i--)
{
if (!basket.BasketCoupons[i].Coupon.AllowCombine)
{
if (previousCouponsRemoved.Length > 0)
{
previousCouponsRemoved += "," + basket.BasketCoupons[i].Coupon.Name;
}
else
{
previousCouponsRemoved = basket.BasketCoupons[i].Coupon.Name;
}
basket.BasketCoupons.DeleteAt(i);
}
}
}
else
{
//IF NOT ALLOW COMBINE, REMOVE ALL EXCEPT THIS COUPON
for (int i = (basket.BasketCoupons.Count - 1); i >= 0; i--)
{
if (basket.BasketCoupons[i] != recentCoupon)
{
if (previousCouponsRemoved.Length > 0)
{
previousCouponsRemoved += "," + basket.BasketCoupons[i].Coupon.Name;
}
else
{
previousCouponsRemoved = basket.BasketCoupons[i].Coupon.Name;
}
basket.BasketCoupons.DeleteAt(i);
}
}
}
basket.Save();
basket.Recalculate();
}
else
{
//Invalid Coupon
//Output couponValidityMessage here
}
}
else
{
//"The coupon code you've entered is already in use.<br /><br />";
}
}
else
{
//"The coupon code you've entered is invalid.<br /><br />";
}
}
4)- Now locate following code in CheckingOut(object sender, CheckingOutEventArgs e) method
Code: Select all
//to enable scripted load testing, we need to allow recalculation of the basket hash
if (!string.IsNullOrEmpty(Request.Form["RecalcHash"]))
Code: Select all
string couponCode = string.Empty;
if (Session["CouponCode"] != null)
{
couponCode = Session["CouponCode"].ToString();
if(!string.IsNullOrEmpty(couponCode))
ApplyCoupon(couponCode);
}
//to enable scripted load testing, we need to allow recalculation of the basket hash
if (!string.IsNullOrEmpty(Request.Form["RecalcHash"]))
Re: Coupon for first-time buyers
Thanks so much for the info.
I have tried to make this work with the non-onepage checkout and can't seem to get it to work. Step #2 I did, and then for #3 I pasted that code into the PaymentPage.aspx.cs and then for #4 there is no where to replace since that code only exists in the OnePageCheckout.ascx.cs .
So in short, how can I do this when not using the OnePageCheckout?
Thanks so much for your help.
Kevin
I have tried to make this work with the non-onepage checkout and can't seem to get it to work. Step #2 I did, and then for #3 I pasted that code into the PaymentPage.aspx.cs and then for #4 there is no where to replace since that code only exists in the OnePageCheckout.ascx.cs .
So in short, how can I do this when not using the OnePageCheckout?
Thanks so much for your help.
Kevin
Re: Coupon for first-time buyers
For payment page give a try and locate following code statement
and then put following code block just above it something like
Code: Select all
checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);
Code: Select all
string couponCode = string.Empty;
if (Session["CouponCode"] != null)
{
couponCode = Session["CouponCode"].ToString();
if(!string.IsNullOrEmpty(couponCode))
ApplyCoupon(couponCode);
}
Re: Coupon for first-time buyers
I can't seem to get it to work. I have implemented the Global.asax adjustment and since I am not using the one page checkout, I have implemented the code above on the payment.ascx.cs file in the ConLib. The pages load without errors and things after the code is implemented, however, the coupon is not applied.
I am wondering if either the coupon in Global.asax is not being set to string correctly or if the Payment.ascx.cs file is not catching it correctly.
The goal is to pass a coupon a url. Then when the user checks out, the coupon will be applied automatically to their order as if they entered the coupon manually.
Can someone please help? I would really appreciate it. Thanks Mazhar so much for your help on this.
Thanks is Advance.
I am wondering if either the coupon in Global.asax is not being set to string correctly or if the Payment.ascx.cs file is not catching it correctly.
The goal is to pass a coupon a url. Then when the user checks out, the coupon will be applied automatically to their order as if they entered the coupon manually.
Can someone please help? I would really appreciate it. Thanks Mazhar so much for your help on this.
Thanks is Advance.