Coupon only for customers not in a group
Coupon only for customers not in a group
I noticed that there are a lot of post about people trying to do complicated things with coupons. I just need to do something simple, but I am stumped.
Most of my customers are not assigned to a group. These are my retail customers and the ones I want my coupons to apply to. I want to make coupons that apply to everyone that is not in a group and exclude everyone that is in a group. This coupon should also work for new customers that have not registered.
I know how to asign a coupon to a group, but how do I exclude all customers that are assigned a group?
Most of my customers are not assigned to a group. These are my retail customers and the ones I want my coupons to apply to. I want to make coupons that apply to everyone that is not in a group and exclude everyone that is in a group. This coupon should also work for new customers that have not registered.
I know how to asign a coupon to a group, but how do I exclude all customers that are assigned a group?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
Re: Coupon only for customers not in a group
maybe make a group called "no group" and make it so all non users are assigned to this group automatically.
Re: Coupon only for customers not in a group
Is there a way to automatically asign a group? Would it work for those who choose not to make an account? Is there a way to quickly asign all my old customers to this group?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
Re: Coupon only for customers not in a group
You can try something like below to automatically add customers to some user group. For example below code will put customers into a group with group id 11
Code: Select all
foreach (User user in Token.Instance.Store.Users)
{
if (!user.IsInGroup(11))
{
UserGroup userGroup = new UserGroup(user.UserId, 11);
user.UserGroups.Add(userGroup);
user.User.Save();
}
}
Re: Coupon only for customers not in a group
Thanks! Now, where would I put this code? Will this do anything to help me reasign all the existing customers?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
Re: Coupon only for customers not in a group
Please read following post. You can place some button one some suitable page to carry this out
viewtopic.php?f=42&t=9207
viewtopic.php?f=42&t=9207
Re: Coupon only for customers not in a group
Just one more question. Does the script only put unassigned users in a group, or will it affect users that are already assigned to a group?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: Coupon only for customers not in a group
Another approach that might be simpler would be to make a custom change to the control that accepts a coupon code from the customer. You could create your coupon and not apply a group filter. Then in the coupon code control, add a little bit of code something like:
And wrap that around the line that applies the coupon. Then you won't have to do anything with automated group memberships.
Code: Select all
if (couponcode == "mycode" && user is not in a group)
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
-
- Lieutenant Commander (LCDR)
- Posts: 91
- Joined: Mon Sep 22, 2008 8:37 pm
- Location: Northeast Ohio
- Contact:
Re: Coupon only for customers not in a group
If anyone tries this method with success please, please, please post back with the code used to make it work and any comments on your experience in getting it to work. We have been looking for a way to give out coupon codes to everyone - which includes advertising in print/web/etc to prospective customers who would not yet be in a group. This would be a HUGE deal for us if it works.Logan_AbleCommerce wrote:Another approach that might be simpler would be to make a custom change to the control that accepts a coupon code from the customer. You could create your coupon and not apply a group filter. Then in the coupon code control, add a little bit of code something like:
And wrap that around the line that applies the coupon. Then you won't have to do anything with automated group memberships.Code: Select all
if (couponcode == "mycode" && user is not in a group)
@Logan: I'm not an expert code writer so a lot of this stuff is very foreign to me. How would I "wrap that around the line that applies the coupon"?
Thanks!
- Jeff
Wave Werks
Wave Werks
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: Coupon only for customers not in a group
In the files ConLib/CouponDialog.ascx.cs and ConLib/PaymentPage.ascx.cs, there is code that looks something like this:
This is the area that is best suited to implement exclusions for coupons that should only apply to users without any group assignment. The code would be changed to something like this:
With this modification, you just provide a list of coupon codes that should only apply to users without a group. Make sure to enter them in all upper case characters.
Then, further down the code (maybe 50 lines down) will be code like this:
The code is slightly different between the two files but this is where the message is being set for an invalid coupon. You will probably want to show a message particular to the situation where a coupon code is not valid because of the group exclusion:
Code: Select all
if (coupon != null)
{
if (!CouponCalculator.IsCouponAlreadyUsed(Token.Instance.User.Basket, coupon))
{
Code: Select all
if (coupon != null)
{
// THIS IS A LIST OF COUPON CODES THAT SHOULD ONLY APPLY TO USERS WITHOUT GROUP ASSIGNMENT
// ENTER THE CODES IN ALL UPPER CASE
string[] noGroupCoupons = { "NOGROUP1", "NOGROUP2" };
// THIS CODE CHECKS IF THE COUPON REQUESTED IS IN THE NO GROUP LIST
bool couponAppliesToNoGroup = (Array.IndexOf(noGroupCoupons, coupon.CouponCode.ToUpperInvariant()) > -1);
// A COUPON PASSES GROUP CHECK IF IT IS NOT IN THE NO GROUP LIST, OR THE USER HAS NO GROUPS
bool passesGroupCheck = (!couponAppliesToNoGroup || Token.Instance.User.UserGroups.Count == 0);
if (!CouponCalculator.IsCouponAlreadyUsed(Token.Instance.User.Basket, coupon) && passesGroupCheck)
{
Then, further down the code (maybe 50 lines down) will be code like this:
Code: Select all
InvalidCouponMessage.Text = "The coupon code you've entered is already in use.";
Code: Select all
if (!passesGroupCheck) InvalidCouponMessage.Text = "The coupon code is only available to retail customers.";
else InvalidCouponMessage.Text = "The coupon code you've entered is already in use.";
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
- hassonmike
- Lieutenant (LT)
- Posts: 76
- Joined: Tue Apr 19, 2011 2:13 pm
- Contact:
Re: Coupon only for customers not in a group
Logan, I tried the code you suggested, but is still accepting coupons from users in groups. I see that this post is kind of old, might there be some changes needed to bring this up to date?
-
- Ensign (ENS)
- Posts: 17
- Joined: Thu Apr 07, 2011 4:31 pm
Re: Coupon only for customers not in a group
Has anyone successfully added this? I, too, added the code, but it didn't seem to make a difference. Our dealers are combining volume discounts with a coupon, and if I specify which groups can use the coupon, regular customers can't use the coupon.