Needs work
Project:
Ubercart Discounts (Alternative)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2009 at 16:56 UTC
Updated:
9 Aug 2010 at 23:04 UTC
Jump to comment: Most recent file
Comments
Comment #1
chrisschaub commentedHere's a patch to set a maximum quantity (either by count or price) for a discount. This patch was rolled against BETA9 which seems to be HEAD. It adds an optional admin field for maximum quantity. This allows for discount schemes like 1-10, 11-21, 22-50 etc.. The current code can kind of do this, but only with weighting which means tiered discounts cannot combined with other more global discounts. This new feature will allow tiered quantity discounts that can be combined with other global discounts. It adds a new db column, qualifying_amount_max.
I've only quickly tested this with quantity discounts, and it could use a lot more testing. Use at your own peril!
Comment #2
ryangroe commentedVery cool. I will take a look. Thanks.
Comment #3
chrisschaub commentedI'm going to re-roll this patch against beta 12 once I test, in a few hours.
Comment #4
ryangroe commentedThanks.
Comment #5
chrisschaub commentedHere's the patch updated for BETA 12.
Comment #6
ryangroe commentedLooks good. I am going to modify it to have a flag to turn this on and off. I think this will be less confusing for other user. I should have this ready in about 2 hours (I have some other changes to make too).
Comment #7
ryangroe commentedI changed the code from:
$order_qualifying_amount > $discount->qualifying_amount_max
to:
$order_qualifying_amount >= $discount->qualifying_amount_max
That way if you have a discount that is $100-$200 (qualifying amount is $100, max qualifying amount is $200) and another that has a qualifying amount of $200, and a cart has exactly $200 worth of items, the cart will trigger the second discount reliably.
I am also not sure if we should show warnings on exceeding the max qualifying amount. It seems like the right behavior looking at the module as a whole but it might be confusing to a user. I'll leave the warnings in because this change is for you and I want it to work the way you need it.
Thanks again for the patch.
Comment #8
chrisschaub commentedGood catch, thanks!
Comment #9
ryangroe commentedOK, beta 13 is ready.
Comment #10
chrisschaub commentedWait, not sure this is right. I think this line ...
is important with the > operator because the user is entering a min/max numbers like 2/3 -- they'd expect it to work for at least 2, but no more than 3. If you do >=, then the discount won't get triggered for a max qty 3 -- it will just continue to the next discount. This if statement isn't for qualifying but rather for disqualifying if over the max. It shouldn't hurt your situation of exactly $200 since that isn't over the max.
Comment #11
ryangroe commentedI think that makes sense. Generally in programming you get a lot of [min, max) conditions. I was trying to avoid people having to put in $2/$2.99 but that may make more sense for the average user. Make that change on your system and I'll release a beta 14 with that change later tonight.
Comment #12
chrisschaub commentedYeah, this took me a second look as well, thanks for the hard work. Let me know if I can help out in any other ways.
Comment #13
ezra-g commentedLooks like this has been committed for a while.
Comment #14
lonehorseend commentedThere is a major bug in this for 6.x.2.x-dev!
The lines starting at 199 have
$form["discount_set"]which isn't declared until after the qualifying_amount_max array stuff, so of course it fails.
It needs to be changed to
$form["qualifications"]I'll attach a patch for this later tonight.
Comment #15
robbertnl commentedRan into the same issue for this version (after upgrading).
More detailed (thanx to #14):
Adjust the following lines in uc_discounts.admin.inc to:
199 $form["qualifications"]["qualifying_amount_max_header"] = array(
204 $form["qualifications"]["has_qualifying_amount_max"] = array(
215 $form["qualifications"]["qualifying_amount_max"] = array(
226 $form["qualifications"]["qualifying_amount_max_footer"] = array(
Is a patch already available?
Comment #16
ezra-g commentedMarking as active. It would be great if someone could roll a patch for the proposed change.
Comment #17
robbertnl commentedPatch
Comment #18
lonehorseend commentedThere is also an error on line 212 which is setting the maximum value variable. Instead of using the maximum_value, it is using the roles value.
Comment #19
redhatmatt commentedAdded the patch to my local install, took it just fine, doesn't seem to do anything... 2x-dev. Trying Qty say 6-11, and tried what was mentioned 2/3... nothing won't take.
Comment #20
redhatmatt commentedHave tried latest 1x beta which adds the flag for max but can't figure out how to use it.
and
The 2x fails in about every way I have tried. Not sure if it was ever supposed to work.
Again, would love to see a new release.
Comment #21
redhatmatt commentedsince the previous items were for 1x, and the later were for corrections for 2x screwed up by 1x patches, could we focus on the 2x and someone roll the changes for a GOOD 2x full patch?
thanks.
Comment #22
redhatmatt commentedhere you go, this is for peeps wary of this story and the multiple patches. max.patch does work, this is merely the patched file and all you should need to get this working. This does not implement any change that #18 mentions as it works without. After working on so much of this I may ask to co-maintain soon. This is a very important module and so far the discounts framework I find severely lacking... but could be wrong.
Remove .txt off the end before adding obviously
Comment #23
charlie-s commentedThis is indeed a very important module, and discount framework is indeed lacking, no offense intended to its coders or anything like that. I posted a message over on the UC forums earlier and I'll say it again here:
I had spent over 20 hours over the past month and a half trying to get some very simple, but very specific, discounts in an Ubercart store via conditional actions & the discount framework. They really couldn't be done. Once I stumbled upon Ubercart Discounts Alternative, I got them working in -- I kid you not -- 15 minutes.
That's my rant. Thanks for the patch -- adding "maximum quantity" gives this module nearly all of the limiters that it will need. I'm sure specific use cases will find a few more and get this thing to cover 95% of usage cases.
Comment #24
rsbecker commentedI think this module is great. But even after applying the patch in #22 I'm still having a problem.
I have set up a member price for something and limited the quantity available at that price to 2, and a member can only use the discount one time. But the discount appears in the cart for 2 items every time that member makes a purchase. So the module is honoring the initial quantity limit, but apparently not checking the member to see if s/he has already used the discount.
I have checked the members profile and the previous purchases are appearing in the order history.
Comment #25
rsbecker commentedI have done some further experimenting and found another problem. If the Discount Type is set to Fixed Amount Off and the Maximum Times Applied is set to 2 the discount is applied only 2x, even if the person orders more than 2 of the item. If the Discount Type is set to Fixed Amount Off per Qualifying Item and the Maximum Times Applied field is 2 the cart says it will apply the discount twice, but it actually applies the discount to the total number of items matching the SKU.
There may be a distinction I'm missing between Fixed Amount Off and Fixed Amount Off Qualifying Items, but I cannot figure out why it works one way and not the other. I would have expected to get a better result from the latter.
I still have not figured out why if the discount is set to be applied to a user only once it applies to the user every time s/he makes a purchase. IOW, I set Maximum Uses by User to 2 and Maximum Times Applied to 2. Each time User A makes a purchase s/he gets the discount on up to 2 of the items, despite having made a previous purchase.
This is so even after the most recent patch above.
Comment #26
davidburnsSetting status to Needs Work based off comment above.
here's instructions on rolling a proper patch http://drupal.org/patch/create