5 replies [Last post]
Adrian's picture
Offline
Joined: 04/09/2008
Juice: 19
Was this information Helpful?

When the discount type "price" is chosen, the "discount value" is applied for each product in the order while when its set to percentage the percentage discount is applied to the order as a whole.

I need a set price discounted to the order as a whole.

mokargas's picture
Offline
Joined: 07/01/2009
Juice: 24
Re: uc_coupon discount type "price" is discounting each product.

Has this been solved in the 2.x version? I'm getting the same thing.

lesliewu's picture
Offline
Joined: 09/05/2009
Juice: 45
Re: Re: uc_coupon discount type "price" is discounting each prod

I need a fixed discount per order too.

dlfroe's picture
Offline
Joined: 01/26/2010
Juice: 13
Re: Re: Re: uc_coupon discount type "price" is discounting each

I had the same problem. What I did was modify the uc_coupon.module file to force the coupon discount price to be subtracted from the "whole order" and NOT with each product.

In the uc_coupon.module file look for the following code:

 $result->valid = TRUE; $result->code = $code; $result->cid = $coupon->cid; $result->title = t('Coupon: @code', array('@code' => $code)); if ($coupon->type == 'percentage') { $result->amount = $applicable_total * $coupon->value / 100; } else if ($coupon->type == 'price') { $result->amount = min($applicable_total, $coupon->value); $result->amount = min($applicable_total, $applicable_qty * $coupon->value);  } return $result;}

Edit the line

 result->amount = min($applicable_total, $applicable_qty * $coupon->value);

and remove the

$applicable_qty *

variable and operator to read as:

$result->amount = min($applicable_total, $coupon->value); 

This modification works great for me ... hope it helps!

Dwight

j.mead's picture
Offline
Joined: 07/27/2009
Juice: 385
Dwight - Thanks for that,

Dwight -

Thanks for that, the coupons I've been using have only been % based as my products are priced very low but sold in multiple quantities and the price function was utter chaos if i tried to use them. This should help me issue a refund coupon very nicely, or even just a $xx promo coupon as what I originally intended to offer my customers.

Have there been any side effects that you've noticed? I started testing on my test site and it seems fine but I have to do more before changing the production site. I'm not that great reading through code and 1 very small edit seems almost too good to be true. But you say it works for you, so again thanks.

I did notice that it didn't exclude an item that I tagged as not applicable, so it was the whole order total but that's what your change addresses so it's not something I expect you to deal with. More testing on my side.

the sites i'm always breaking.... www.sew-la-fabric.com
http://lostpetsla.com (though i hope i never break this one too bad)

jasonabc's picture
Offline
Uber Donor
Joined: 05/05/2008
Juice: 573
Re: Dwight - Thanks for that,

Had this exact same problem - for price discount codes - the discount $ amount was being applied to each applicable product in the cart. Dwight - thank you so much for the fix!! Works like a charm! Have you raised this on the uc_coupon issue queue over on DO? The maintainers need to get your fix into core asap as it's a pretty bad error.

thanks again

Jason