Needs work
Project:
Ubercart Discount Coupons
Version:
6.x-1.5
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 May 2010 at 16:00 UTC
Updated:
26 Jan 2011 at 00:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sonlinemedia commentedI am having the same issue. Our products are $10 each and I want to give them $10 off if they order more than 2, however if the customer order 2 + then it gives them $10 off each item in return making it FREE....
Comment #2
sonlinemedia commentedOk, I've looked into the code on this module and here is what it is doing on the "price" discount.
LINE @ 928 -> uc_coupon.module
I have adjusted this to the following:
If this adjustment is made the "price" discount will ONLY substract the total you input in. It stops it from multiplying.
Hope this helps anyone needing it :)
Comment #3
sonlinemedia commentedI would rather see this added as another option under the conditional statement myself :) But I don't see all the places that need to be adjusted for this to work. I have copied what I am working on below:
Option under the conditional statement,
Line 924 uc_coupon module:
I did add it as an option to select on the dropdown
Line 280 of uc_coupon module:
This would be a nice feature to have instead of adjusting the once currently on the mod but until that is fully functional I will use the code adjust I mentioned earlier ;)
Comment #4
jaybhancock commented*bump* has any progress been made on this issue?
I have a client who wants to apply only ONE coupon per order. I can do the custom code, however it complicates my maintenance and I'd rather see an option built into the module itself. A simple checkbox to ask "coupon applies to each item or once per order" and then the corresponding logic in the background.
I'm not yet a module developer... is this something that is simple?
Comment #5
pdemarte commentedsonlinemedia,
Thanks very much for this. It's working for me. Your code should be integrated into the module almost as-is.
I say "almost" because I had to change the option value 'price per qty' which in my code became 'priceqty' -- only because the 'type' column in the uc_coupons table only holds 12 characters and 'price per qty' is 13 chars. ;)
Again, thanks. This helped me out considerably today.
Comment #6
longwaveIf someone can provide this as a patch file against the -dev version I will commit it, this is a much-requested feature.
Comment #7
bocaj commentedI was looking for this exact functionality! I modified uc_coupon.module according to sonlinemedia's post (#3 above) and it worked great. I created a patch (using sonlinemedia's code above and as longwave asked for) in hopes that this will be committed soon.
Comment #8
aether commentedThere is a bug in the patch in #7. Array key needs to be 'priceqty' instead of 'price per qty'.
Attaching a patch against dev that corrects this.
Comment #9
bocaj commentedYou are correct, sorry I forgot to make the appropriate change to that key. Thanks!
Comment #10
cangeceiro commentedthis worked for me as well, please commit.
Comment #11
longwaveThe patch in #8 will break compatibility with sites that already have price coupons set up, as the behaviour of these will change. You can get around this issue now by using the coupon restrictions to limit the coupon to the one most expensive item in the cart, except in the case where your coupon value exceeds that amount.
If this is to be committed it will need an update hook in the .install file to change existing "price" type coupons to "price per qty" for coupons that don't have any restrictions.
Comment #12
longwaveFinally implemented this in a backwards-compatible way. In -dev you can now select whether the coupon applies to the order subtotal, all matching products, or a set of the N cheapest or most expensive matching products.
Comment #14
Anonymous (not verified) commentedThe patch #8 is making a distinction between applying the coupon on each applicable product and applying the coupon on the sum of all applicable products.
The 6.x-1.5 version let us :
- applying the coupon on the subtotal, maching products or not
- applying the coupon on all maching product, but for each each product, not the sum of them
For exemple, I wan't to create a 5€ reduction coupon only available on "class A" products
if you buy :
- a 2€ "class A" product, a 6€ "class A" product => get 5€ dicount
- a 1€ "class A" product, a 2€ "class A" product, a 5€ "class B" product => get 3€ dicount
But if I choose an "Order subtotal" coupon type, if I buy:
- a 2€ "class A" product, a 6€ "class A" product => get 5€ dicount
- a 1€ "class A" product, a 2€ "class A" product, a 5€ "class B" product => get 5€ dicount
But if I choose an "All matching product(s)" coupon type, if I buy :
- a 2€ "class A" product, a 6€ "class A" product => get 8€ dicount
- a 1€ "class A" product, a 2€ "class A" product, a 5€ "class B" product => get 3€ dicount
I think we should modify the way that an "Order subtotal" coupon deals with restricions to take them into account (is you want the coupon to apply on the subtotal, just don't add any restriction so that matching products = all products)
We would then rename coupon types :
"Order subtotal" => "All matching product(s)"
"All matching product(s)" => "Each matching product"
It would make much more sens for me
It seems that we juste have to replace
by
in the uc_coupon_calculate_discounts function
Comment #15
longwaveI think this needs to be another new option, rather than changing how the current option works; other users might want the existing "order subtotal" discount to only be applied if specific items are already in the cart.
Comment #16
Anonymous (not verified) commentedI see, didn't thought about that
So we could add an new "apply_to" like this in uc_coupon_add_form() (+ adding some lines)
and in uc_coupon_calculate_discounts() we could replace
by
It would do the trick I think