Posted by scottrigby on June 29, 2008 at 11:04pm
| Project: | Ubercart Discount Coupons |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Is it possible for a user to get a discounted shipping, or free shipping, by entering a coupon code?
Thanks in advance for any suggestions–
Scott
Comments
#1
+1
#2
Looking for the same but for 6.x
#3
Same for me with 6.x . Did anyone find anything?
#4
+1 for 6.x please!
#5
+ 1 for 5.x & 6.x
#6
+ 1 for 5.x & 6.x
#7
+ 1 for 6.x
Discount for in store pickup.
#8
#9
Reopening, not sure why this was closed?
#10
Free shipping for Drupal 6, Ubercart 2 can be done through "Conditional Actions". No need for this particular module.
What we did was, under "Flat Rate", add sth like "Free Shipping for Special Products" or whatever you want to name it.
Click "Conditions"
Condition: Check an order's Products
Choose the SKU for whatever product or products you want to discount, and test. If you want ALL free shipping, choose ALL products (or just don't add shipping).
#11
Thanks skyline5k,
Your explanation helped me set up a free shipping option. The question though is if the option for Free Shipping can be made available if a coupon is entered. I noticed under the "Conditional Actions" there is a section for a php snippet. I was thinking maybe on a shipping quote request we could put some php to check if a coupon has been entered. Any idea how to do something like this?
#12
That I'm not too sure about. That hasn't come up in any of the ubercart sites I've built or maintained. I'll look into it though, as I'm sure one of my clients will eventually ask this. I'll see if I can't play around with it sometime soon with my test site.
edit: actually it has been brought up, but we ended up scrapping the idea because of fears that the free shipping could be used on extremely large orders, thereby losing a lot of money just to offer a coupon.
#13
That's a good point. I think the way you'd have to implement it is with total number of products less than three or so. You'd definitely want to take that into consideration when placing the advertisement with the coupon features and restrictions though.
#14
+1 for 6.x -> coupon can be given as a gift, therefor it should make product incl. shipping free for recipient.
#15
I created a new post (http://drupal.org/node/669706) asking for information about what would call the value of the coupon field. The purpose being to add into some custom php code for a condition that would bring up an option for free flat rate shipping. I suppose if I ever find out I will post my results here as well, but wanted to give people watching this thread a heads up. Also, if none of you had thought of this as a possibility, but actually know the answer....
#16
You can check for coupons via conditional actions.
You can "begins with", "ends with", "contains", and "equals" ... seems like a no brainier to test for the free shipping coupon.
What I wish for is that the test was able to recognize when the coupon equals empty, to only allow free shipping when no other coupon is entered. Bummer.
#17
Very sorry. Spoke too soon, module mix-up. The Discount Framework module allows for conditional actions based coupons which can then tie into Flat Rate Free Shipping. However that module is in dev, and shouldn't be used in tandem with this module, as it would add a second coupon field on the checkout page.
#18
My client absolutely wants a coupon that offers "free shipping", so it would be cool if there was a way to tie a coupon to a conditional action under flat rate? I'm not sure how I would go about doing this in PHP...? Thanks!
#19
+1
#20
If anyone interested here is what I gathered so far:
The code to check for coupon validity on The Discount Framework is:
if (uc_discount_validate_coupon($order)) {
$changes[] = t('Coupon code %code redeemed.', array('%code' => $order->data['coupon_code']));
}
So, using the logic from quartarian, if the above function return true and uc_discount_validate_coupon($order) is recognized outside the module(I almost sure it will not) we may be able to validate coupon codes via conditional action and flat rate...
Please let me know where I went wrong!
#21
+1
#22
Hello,
So I have Ubercart 2 on Drupal6.
Ive set up a coupon with a code, and the first thing that perplexes me is that here I can only choose between "discount % or $ off" I tried both 0 and $0.01 just to make sure it needed at least some value.
Then I went into my flat rate, and I have one that is for "free shipping" if the person enters in this coupon.
I hit "CONDITIONS" and then under matching logic, I type in the coupons code.
When I test it, the coupon code is entered, system accepts it "says it has been applied" but the flat rate for "free shipping" does NOT appear
I also tried adding an "action" such as "calculate shipping quote" but this doesn't seem to do anything.
I am able to create flat rates that are range-based in their conditions, but somehow not coupon code based... is this a known bug? or should it work? or am i missing something??
Thanks!!
#23
Another question, this all seems like a big chain of interaction between uc_coupon and uc_discounts_alt (conditional actions)
However, the code of uc_discounts_alt is horrendous, so even starting to look into that module's source is a death wish... I've had two other experienced dev's look at the code and simply refuse to touch it.
#24
+1
Tried my best with conditional actions but couldn't find a way to get this work. Would love to see this as a feature, my client is requesting this.
#25
Subscribing
#26
Got this working yesterday with the uc_discounts_alt modules, once I'd given it a tiny tweak.
There are two places to get discount data. If you want to activate free shipping on a codeless discount, you need to interrogate the results of $discounts = get_discounts_for_order($order, array(), array(), array()), where $order is the order object you have access to in the conditional PHP condition inside your shipping method. If you want to trap errors, warnings, etc., then declare those arrays in advance and pass in the variables.
If you want to use a code, you need to patch uc_discounts.module so that you can trap the code that is entered during checkout. My fix for this was to add
$_SESSION["uc-discounts-codes"] = $_POST["uc-discounts-codes"];
at line 600 of uc_discounts.module.
Once the discounts pane has been posted, I had access to what had been posted and could check the values.
#27
@chrislynch, I took your idea and rolled it into a patch for uc_discounts_alt (#960572: Add in a hook to Conditional Actions for things like Free Shipping). Hopefully it gets committed :)
#28
See comment #27
#29
Oops, just because it's implemented in uc_discounts_alt doesn't mean it will work in uc_coupon :)
#30
I'm in a similar boat... using uc_discounts_alt. I need to have a flat shipping rate of $0 display when the user enters a certain code in the discount codes filed (and not before).
I created a discount item in storeAdmin/config/discountSettings ($0 fixed amount off); then created a Flat rate of $0 with the conditional actions predicate set to "check if a discount has been applied" (and the Discount identified) and the action of "fetch a shipping quote".
I have UPS and USPS set up as shipping methods and when I test it I can see those options but the Flat Rate (of $0) does not show up when I enter the discount code in the shopping cart. After entering the discount code the shipping costs are re-calculated but no flat rate appears.
Any suggestions?
Edit: Problem fixed - not sure what it was but I re-created the discount code and WHA-LA it works!
#31
I am considering adding a "check the currently applied coupon code" condition to Conditional Actions, which would let you do this (you could have a "free shipping" flat rate that is only available with that condition), but there are a couple of issues:
Also, please keep discussion or questions about uc_discounts_alt in the issue queue for that module, as they are more likely to be answered there and only serve to confuse by talking about a similar but separate module here.
#32
I just had the same problem: $0 free shipping coupons rejected as "not applicable to your cart". If the sum value of the coupon == 0, it assumes it doesn't apply to any item and is invalid.
in 6.x-1.5 uc_coupon.module line 403 I changed
if ($amount == 0) {to
if ($amount == 0 && $coupon->value > 0) {which allows any $0 value coupon to fail this validation rejection.
I know it's a hack, but it was a zero-hour fix.
Hope it helps.
#33
I'm also having the same problem. I want some customers to be able to get a code that will show a Flat Rate option called "Pickup". I have customers that will want to purchase and pay tax online and pick up the shirt directly from me. I do not want every customer to see the "Pickup" flat rate option since I will be taking orders across the US.
I tried using the conditional actions tied to the flat rate option i set up for this. I see that the coupon code applies, but doesn't pop up the option once I click "Click to calculate shipping" in the checkout screen?
I'm also having other problems with uc_coupon and flat rate shipping, and I'm not sure where to start. On the checkout screen it will count the coupon discount as an item and raise my shipping price accordingly...once I go to the review it will correct itself. Data is incorrect between each screen, but fixes itself later. I don't want to be changing prices of shipping on the customer, even though they will be saving money on shipping on the review screen.
#34
Subscribing
#35
Subscribing
#36
I've finally had a chance to look into this a bit. The solution proposed by longwave in #31 seems right to me. I will look into working up a patch for this in the next week or two.
Note: this is connected to #1112522: Conditional Action not looking in the right place for current coupon. The patch there would enable you to use the existing conditional action - but be warned: if you use any coupon-checking conditional actions for orders created outside the current session (e.g. on payment notification or manual order status update), that patch will break those configurations, and therefore will not be committed.
@dcarrjr - The two problems in #33 are separate:
- The first (flatrate conditional action not recognizing coupon code) is due to the fact that when you request a shipping quote via ajax, the dummy order object passed by uc_quote to the conditional action doesn't contain the currently applied coupon - the coupon is not added to the order object until the checkout page is processed. This is what longwave's solution in #31 would remedy.
- There is a patch dealing with the second problem (the coupon being counted as a shippable product) awaiting review at #1087524: conflict between flat-rate per-item shipping and uc_coupon.
#37
OK, the attached patch is a variation on #31, but rather than creating a new condition, it provides a checkbox on the existing "Order has coupon" condition, allowing the currently applied coupon to be included in the check. It also allows prevents the rejection of a coupon which causes no discount to be applied if that coupon has a value of 0 (in order to enable a coupon which is only used to give free shipping).
#38
Tested patch in #37 and it seems to work well.
Only one thing and I am unsure if this is related or not but if the coupon is not applied in the CART pane but then applied in CHECKOUT pane, it does not provide the Flat Rate shipping option. I set up the flat rate shipping for FREE SHIPPING and set the condition to "check the currently applied coupon code".
#39
Hm. I can't reproduce this. I can apply a coupon either in the cart or at checkout, and when I click the "Click to calculate shipping" button the free shipping option appears. Note that you do have to click the "Apply to Order" button in the coupon pane first. You also have to click the "Click to calculate shipping" button to update the quotes after the coupon is applied.
What other shipping quote methods do you have enabled, and what are the conditions associated with them? Are there any other conditions associated with the "Free Shipping" method?
#40
I have UPS quote method enabled and no conditions are set for that. There are no other conditions associated with Free Shipping (Flat Rate). Let me know what other questions I can answer about my configuration.
For now, I just removed the COUPON field in the Checkout pane to avoid confusion and will add some instructions to make sure the code is entered in the Cart pane first.
Cheers and nice work!
#41
i don't have a ups account, so i can't test that exact configuration - can you try with the ups account disabled and, perhaps, another flat_rate method as an alternative. Can you also send me the exact series of steps that produce the error. e.g. in my situation:
I have 2 Flatrate methods - one has no conditions, and the other is "Free Shipping" conditional on a coupon with a specific code being applied to the order. The "include currently applied coupon" checkbox is checked.
1. Add a shippable product to the cart.
2. Proceed to checkout
3. Enter coupon code.
4. Click Apply to Order
5. Click Calculate Shipping
this shows the Free Shipping option in the list.
thx
#42
subscribing - my customer wants this feature too
#43
@dalleyasaurus - please try the patch at #37 and let me know if it works for you.
#44
This has been committed and is part of the 1.6 release. Marking as fixed, but please reopen if it crops up again.
#45
To make this effective, shipping should be automatically recalculated after a coupon is successfully applied (or removed).
#46
I considered this - but thought it might be confusing if there is not a coupon-dependent shipping option (or if the shipping rates have not yet been calculated). It then seems odd that when you enter a coupon the shipping quotes pane is updated. I suppose there could be a check to see if the shipping rates have been calculated yet, and they could be updated only if that is the case. I will look into it.
#47
OK. That turned out to be trivial. Please test the attached patch.
#48
What if you wanted to offer 50% off a UPS shipping quote?
#49
@kruser - Don't think this is currently possible, bc the UPS shipping quote module only allows a single UPS quote, so you can't use the same mechanism as you can with flatrate.
#50
Thank you, the patch works well in my testing.
Note, I'm also using a variation of the Ubercart Auto-calculate Shipping module available in the comments section here (by hiddentao): http://www.ubercart.org/project/Auto-Calc#comment-52621 , and this patch works well with it. The Recalculate button hiding code in that module should arguably be removed, though, on the off-chance a coupon is applied in the middle of a shipping calculation (i.e., comment out "shipping_button.hide();" )
#51
I wish there was just a simple way to give free shipping when customers use a coupon code. One of my clients want to do a couple of big social networking campaigns, and the discount they want is free shipping. Their shipping set-up is already a conditional actions nightmare (lol between affiliates, and wholesale and international for both etc..) and as a marketer, I don't want something that will just put zero in for free shipping- it actually needs to show people they are getting free shipping when they enter the coupon. I thought the uc_free_shipping_quote module was my saving grace- but it can only be applied to EVERYONE when they purchase certain products-
For example 1 of their campaign is this:
(1) Facebook Landing Page - users click "LIKE" to get a coupon
(2) Users click like and the coupon code appears
(3) They go to the site, place their order and enter the coupon code (free shipping)
(4) They get their orders and are happy customers. =)
I wish I knew much more php than I do, because this seems like it should be something fairly simple =(
#52
#51, what do you mean by "show people they are getting free shipping"? Is it not enough to name the flatrate shipping that is activated by conditional action "Free Shipping Coupon"?
As for the message, "A discount of !amount has been applied to your order," (in uc_coupon.module, I believe line 1018), I just changed it to "A coupon has been applied to your order".
As a feature request, spitting out a generic message if $amount is equal to zero would be a good idea. And if the user so desires, they can use string overrides to change the generic message, where for example, all zero-dollar coupons will be used for free shipping.
I'm not very good with PHP, and I haven't really testing this, but something like:
if ($amount == 0) {
if (variable_get('uc_coupon_show_in_cart', TRUE) || $context != 'block') {
$coupon->message = t('A coupon has been applied to your order.', array('!amount' => $amount));
}
else {
$coupon->message = t('A coupon will be applied at checkout.', array('!amount' => $amount));
}
}
else {
if (variable_get('uc_coupon_show_in_cart', TRUE) || $context != 'block') {
$coupon->message = t('A discount of !amount has been applied to your order.', array('!amount' => $amount));
}
else {
$coupon->message = t('A discount of !amount will be applied at checkout.', array('!amount' => $amount));
}
}
#53
I am a little confused and trying to follow the thread above.
#44 says That this is set and has been committed to 1.6 and was marked as fixed.
But then #47 says
Since 47 comes after #44 I am not sure what to do, use the newest release (1.7 at this time) or apply the patch(s) to the dev? I installed 1.7 but see nothing in the Ubercart Coupon UI to indicate anything about free shipping. I kind of thought I would see something when creating a new coupon about "free shipping".
It also looks like the patches are different. I apologize if all this is not self evident. I think most of this is my not knowing how to create free shipping with this new functionality to sum things up. Thanks.
#54
No need to apply a patch if you are using the latest release (1.7) - all is included (though not Nutty's code from #52).
Free shipping is not a built-in feature of uc_coupon - but it is possible using conditional actions with uc_coupon and uc_flatrate.
1. Create a new flatrate shipping method with a rate of 0. (admin/store/settings/quotes/methods/flatrate/add).
2. Add a "Check if an order has a coupon applied" condition to the method you just created. Specify the coupon code you want to produce the discount, and make sure the "Include currently applied coupon" box is checked.
The new method should now appear in the shipping quotes section of the checkout page when the specified coupon is applied.
In addition, a variation of Nutty's suggestion from #52 has been committed to DEV.
#55
Automatically closed -- issue fixed for 2 weeks with no activity.