Page 1 of 1
Getting Coupon Minimum Order to base on total cart subtotal
Posted: Fri Dec 24, 2010 1:32 pm
by Brewhaus
We are trying to add a coupon for a specific free item with a set minimum order. The problem is that when we enter the minimum order, the coupon only works if the minimum value is met by the cost of the promo item. For example, to get item A free with a $50 order, you need to have $50 worth of item A in your cart or the coupon will not work. What we want is to have the price of item A be zeroed (basically through a coupon that offsets the price of item A) if the cart subtotal is $50, regardless of what items are in the shopping cart. How can we go about this?
Also, is there any way to have a coupon be automatically applied if the criteria are met, or must the customer enter the code at the checkout? There should be an option to auto-apply a coupon.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Dec 30, 2010 9:31 am
by mazhar
Well first about apply coupon code automatically have a look at following thread
viewtopic.php?f=42&t=9030
About your first requirement where you want to use product coupon but that doesn't works because product is not in cart at time when some one applies the coupon. What about creating some custom interface for applying your coupon code where you can put some code that can first determine what sort of coupon is getting applied by customer. Then depending upon coupon first you can add desired item to basket and then apply coupon code on basket. I think this can do the trick.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Dec 30, 2010 7:24 pm
by Brewhaus
Thank you- I will look at the thread you suggested for getting the coupon to be automatically applied.
As for the minimum value, I am not sure that you understand our needs. We want to enter a coupon so that a customer can get a free product (the value of the coupon will equal the retail price of the product) as long as their entire cart meets a minimum value. The way that the coupons are set up in AC, if we apply the coupon to a specific product, then there must be enough of that item to meet the minimum order value. Specifically, we want to give a free t-shirt with a minimum $50 order. If we set the coupon up to be $11.99 off, and set the products to be the t-shirt, then a customer must have $50 worth of t-shirts in their cart for the coupon to work. We need for the coupon to be valid if the customer's shopping cart is at least $50, regardless of the items, but the coupon is only valid if a t-shirt is also in the cart (ie. a customer cannot apply the coupon if their cart exceeds $50 unless a t-shirt is in the cart).
From what I can tell, we just need AC to look at the cart subtotal to decide whether or not the coupon is valid, not the subtotal of the t-shirts in the cart.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Mon Feb 28, 2011 4:37 am
by leena1471
keep up the good work Great work.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Mon Mar 21, 2011 8:44 am
by katiebruno
I just had this same issue, was a resolution ever decided upon?
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Mon Mar 21, 2011 12:28 pm
by AbleMods
I've used the ApplyCoupon() code mentioned above to manipulate basket totals. It works nicely.
For one project, we used category membership as a way to determine if the basket qualifies for the free item. If anything in the basket was a member of a specific (hidden) category, then the trigger is fired. A coupon is applied to the order in the background and the AC7 logic takes it from there, all before the first checkout page displays.
Managing the "trigger" products was just a matter of assigning certain items to the "magic" hidden category. Then the coupon has to be configured to apply a credit for those same products. Not as elegant as it could be, but it works.
Overall took 3-4 hours of programming work for all the setup, testing etc.
In your case, you might want the modifications to also automatically add the t-shirt product to the basket AND THEN apply the coupon. That way the customer doesn't feel "cheated" out of their free shirt because they forgot to add it themselves.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Wed Mar 23, 2011 8:00 pm
by Brewhaus
For one project, we used category membership as a way to determine if the basket qualifies for the free item. If anything in the basket was a member of a specific (hidden) category, then the trigger is fired. A coupon is applied to the order in the background and the AC7 logic takes it from there, all before the first checkout page displays.
I think that you may have lost me. When we tried specifying what product was required in order for the coupon to work it required the specified items to make up the minimum value before the coupon would work. We could have $1000 in the cart, and one T-shirt, and the coupon would not work. It required us to meet the minimum value on just those products specified.
Or, am I missing something?
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Mar 24, 2011 7:13 am
by AbleMods
Ok sorry didn't mean to lose you on that one.
Here's all that has to happen for your particular scenario:
Add a private-visibility item for the free t-shirt. Set it's price to 0. Don't worry, it's private so no shoppers can see it.
Then modify checkout so that in Page_PreRender() it checks the basket total. If the basket total exceeds the threshhold you want ($1,000), see if the free t-shirt is already in the basket. If not, create a basketitem object for the free t-shirt and add it to the basket.
No coupon is really necessary in your situation since coupon logic doesn't work the way you need. So you are going to need some programming to make it behave the way you want.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Mar 24, 2011 7:50 am
by katiebruno
Any ideas on how to allow the user to select T-shirt size?
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Mar 24, 2011 8:16 am
by AbleMods
katiebruno wrote:Any ideas on how to allow the user to select T-shirt size?
That does add some more complexity but it's still doable. You could add a dropdown on the 2nd page of checkout where they can choose the shirt size. It's visible only if the free shirt is in the basket. Then just set up additional (private) products for each shirt size and add the proper one based on the dropdown selection.
Or you could redirect to a whole new page upon entering checkout if the basket qualifies. That new page could process the free shirt size input and then jump back to checkout. More page jumps that way, but easier to manage the programming and minimizes the risk to breaking checkout functionality.
OnePageCheckout is always a nightmare to modify. I avoid it unless it's absolutely necessary. Even if it means an additional page or whatever. Nothing scares away online shoppers more than a broken checkout page.......
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Mar 24, 2011 5:54 pm
by Brewhaus
Could we not just replicate the "Basket Header" programming That shows the amount in the basket, but do this on the checkout page by adding a link if the basket value is exceeded? That could take the customer to a page for the free t-shirt, with a link back to the checkout.
The only problem with this is if they delete a product from their cart and they fall below the minimum value, the free product will still be in their cart. They could even feasibly delete all of the other products and order nothing more than a free t-shirt. Any thoughts?
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Mar 24, 2011 8:36 pm
by AbleMods
Brewhaus wrote:The only problem with this is if they delete a product from their cart and they fall below the minimum value, the free product will still be in their cart. They could even feasibly delete all of the other products and order nothing more than a free t-shirt. Any thoughts?
That's why you want the code in Page_PreRender(). It should remove any existing hidden t-shirt products from the basket before running the calculation. That way you're guaranteed protected against both basket changes and duplicate free t-shirts.
Either way will work. Forcing it in Page_PreRender() is easier, has less pages involved and doesn't require any back-and-forth jumping for the shopper. It's cleaner that way imho.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Fri Mar 25, 2011 6:15 am
by jmestep
I'm not sure this would apply to your scenario, but we made code for a BuyOne,GetOne offer and are getting ready to package it as a plugin.
Merchant sets up a coupon for a product with 100% off and whatever other criteria.
In the product edit page, merchant selects what BOGO offer to apply to a product.
The free products can be any product that the coupon applies to.
When customer clicks to add a Buy One product to the cart, a page similar to the product accessories page comes up and the customer can select the Get One product- it can be any product the coupon applies to, any option such as size.
The coupon gets applied automatically behind the scenes.
BOGO.png
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Fri Mar 25, 2011 6:43 am
by Brewhaus
I've got you now, Joe. That solution would likely work, but how much of a nightmare is the programming of it? I have never gotten quite that crazy on the programming, so I would be lost if it becomes very involved.
Judy- If I understand your add-on, it would not function properly for us as we want all products to be used when calculating the basket total (to confirm that the order qualifies), but offer only a specific product for free.
One other question- is it possible to use the 'options and variants' (or some variation of this) to select size, but still have inventory tracking for the different sizes? We have not used the options for selecting size before because of this, but it would be nice to only offer one 't-shirt' item with a drop-down for selecting size, instead of having to offer multiple products.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Sat Mar 26, 2011 7:50 am
by AbleMods
Brewhaus wrote:I've got you now, Joe. That solution would likely work, but how much of a nightmare is the programming of it? I have never gotten quite that crazy on the programming, so I would be lost if it becomes very involved.
Some things are easier done, than said
I wrote an article on my blog for you that explains how to do it and includes all the code to make it work the way you want. You can find it here:
http://www.ablemods.com/Blog/post/2011/ ... rce-7.aspx
Brewhaus wrote:One other question- is it possible to use the 'options and variants' (or some variation of this) to select size, but still have inventory tracking for the different sizes? We have not used the options for selecting size before because of this, but it would be nice to only offer one 't-shirt' item with a drop-down for selecting size, instead of having to offer multiple products.
Certainly. Just set up a product and set it's inventory mode to Track Variants. Then go to variants and add an option for Size. In variants, you can have a different inventory stock level for each variant. In your case, each variant (in a one-option variant setup) would be the Size.
However making this work with the free-item scenario is far more complicated since now you can't just add the item to the basket. You have to get some input from the user to decide on the size of the item. In that case, it might be better to add the free item when the Add-To-Cart button is clicked. Then A) you're not messing with checkout at all and B) you have an easier place to modify to acquire that "Size" input needed from the shopper.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Sun Apr 03, 2011 7:03 pm
by Brewhaus
I get the following error when going to the checkout after pasting the code:
[[ConLib:Custom/OnePageCheckout]] e:\Websites\Hot Sauce Depot\ConLib\Custom\OnePageCheckout.ascx.cs(243): error CS1002: ; expected
Rick
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Mon Apr 11, 2011 7:53 am
by AbleMods
Sounds like something didn't get copied right - the code builds fine in my test 7.0.6 install.
Post your OnePageCheckout.ascx.cs file as an attachment and I'll take a look at it for you.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Mon Apr 11, 2011 1:50 pm
by Brewhaus
Here you go. I had to zip it in order for the forum to accept the file. I appreciate the help.
Rick
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Tue Apr 12, 2011 8:28 am
by AbleMods
I loaded up your OPC code file into my test install and I'm not getting any exceptions. Seems to work just fine.
Looks like you uploaded the original OPC file and not the modified one. Can you upload your modified one that was throwing the exception?
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Wed Apr 13, 2011 8:44 pm
by Brewhaus
Sorry Joe- I thought that you wanted to see the original file to see if there was a problem. The file with your code added is attached. I re-tried it, and get the same error at the Checkout/Default.aspx page.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Apr 14, 2011 7:07 am
by AbleMods
No problem.
I found the issue. You missed the copy/paste by 1 single character
Edit your file and find the Page_Init() function. Add a squiggly-bracket as shown below:
Capture.JPG
Now scroll further down until you see this section of code. REMOVE the squiggly-bracket I've indicated:
Capture1.JPG
Once you've done both steps, save it and give it another try.
What happened was you pasted my code before the starting squiggly-bracket of the function, so ASP.Net doesn't understand the commands. All commands of a function must be contained within the squiggly-brackets.
And yes, that's my technical term for braces.....squiggly-brackets

Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Apr 14, 2011 7:31 pm
by Brewhaus
Dang, your technical term had me really messed up!
That did work... now, how can we go about getting the customer to choose a size? I do like the idea of sending the customer to another page as it makes them realize that the item has indeed been added to the cart.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Apr 14, 2011 8:30 pm
by AbleMods
Brewhaus wrote:That did work... now, how can we go about getting the customer to choose a size? I do like the idea of sending the customer to another page as it makes them realize that the item has indeed been added to the cart.
Glad it worked out.
I'm not entirely sure how to offer a size choice. I would say modify checkout to see if the shirt exists in the basket. If so, display some sort of size choice list and adjust the basket item SKU based on the choice made. However that would require more time than I have right now, gotta stay focused on my project list - last weeks vacation put me behind schedule.
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Fri Apr 15, 2011 6:43 am
by Brewhaus
I went through the file and wonder if you can tell me how to just replace the automatic addition of the item to the cart with the code to redirect to a web page (obviously it would be the product page) if the item is not in the cart already. I believe that it should just be redirecting, or maybe just adding a popup that allows the customer to select 'Add' (which directs to the product page) or 'Cancel' (if they do not want to add the free item). Then we can put the free item in a category using an altered CategoryGrid file so that when they add the item they are not directed back to the basket, but instead directed back to the checkout page that they were on. If I am correct, this would be the simplest option (as we just direct to a product page instead of automatically adding the item to the cart), and would allow for the addition of the item with size selection. I am just not sure how to replace the automatic addition of the item to the cart with a redirection (or better, create a popup).
Does this sound like it would be a good / simpler option?
Re: Getting Coupon Minimum Order to base on total cart subtotal
Posted: Thu Jul 07, 2011 1:28 am
by wilsonsmith012
Sorry, I do not know how to apply these coupons automatically for the criteria. But I like your way to provide free printable coupons.