Hi longwave,

I had been working in this thing for a while and I always thought of sending it back to you for review and discussion. I am not submitting this as a patch, mainly because it will probably be easier to review as a separate module, and I also knew this was unlikely to be accepted, and I wanted to keep the uc_coupon code up to date.

The main problem we faced using uc_coupons out of the box was that we have vat and not vat products on our site. As coupons are applied as order line items, they are only applied against the non-vat value stored on the db. I could always tax the coupon, but then it would tax the whole amount of the coupons.

The solution I have come up with is to apply the coupon on a per product basis, directly on the cart, instead of in the checkout. Eventually, the two of them may work together w/o problem. Doing this, the product appears to ubercart with the discounted price, and the rest of the tax logic works as expected.

I am modifying the cart prices using hook_uc_cart_alter (or something like that). Maybe you are interested in merging this functionality to uc_coupon? I would think there would have to be two different coupon types, product coupon (cart) and whole order coupon (order) and you can choose to enable the cart or checkout pane as you need.

Besides a small bit of your logic which I hall to pull into this module, the rest is just relying on uc_coupon for everything.

Worth mentioning that for this particular site, I am still using uc/uc_vat rc3, but it should be the same for the newest version.

Comments

longwave’s picture

Status: Active » Needs review

Thanks for contributing this, I will put this on my pile of things to review when I get some free time. In the meantime if anyone else would like to review this for inclusion, please do!

longwave’s picture

Title: applying coupon on a per product basis » Apply coupon directly to cart item prices
Status: Needs review » Needs work

Mixed VAT rate products are now (finally) correctly supported. I guess modifying cart prices directly could still be done, though this patch is now severely out of date.

hanoii’s picture

Is it? the module uses a few internals of coupon module but I would think it should be working, at least I am keeping uc_coupon up to date and all seems OK on the client's site. I will check better some other time.

longwave’s picture

From a quick look, it only handles percentage based coupons, and the restriction checks in _uc_coupon_extra_cart_item_apply() need updating somewhat.

There is a new option to show coupons directly in the cart, so ideally that would have to be extended to "show coupons as a line item", "show coupons in the cart" and "apply coupon directly to product prices".

hanoii’s picture

what does that new option does? shows the coupon discount as a cart item? separate cart pane?

longwave’s picture

Shows the coupon discount as a cart item.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new4.58 KB

First attempt at a patch that attempts to implement this against current CVS. Seems to mostly work, except the cart block prices change on the checkout page for some reason, and there can be minor rounding errors where VAT is involved.

paulgemini’s picture

Has anyone else tested this? I have a live site up so I'm wary about trying it, but if anyone else has, I could really use this function!

wodenx’s picture

My guess is that the patch is now quite out-of-date.

wodenx’s picture

Status: Needs review » Needs work
wodenx’s picture

Status: Needs work » Needs review
StatusFileSize
new4.56 KB

I have updated longwave's patch from #7 to apply to the current HEAD, and fixed the problem with cart block prices on the checkout page. However, I haven't tested this extensively, so use it with caution - and please report any test results here.

carolinedrupal’s picture

Thank you so much for creating this patch. When I install it on uc_coupon 6.x-1.7, it says uc_coupon.module has type 100755, expected 100644, then it can't find $coupon->message = items etc. Is it a patch for Drupal 7?

wodenx’s picture

No - it's a D6 patch, but it doesn't apply to 1.7 - please try with the current -dev branch and post back with any issues.

tomas.teicher’s picture

Is this possible to achieve also in D7?

wodenx’s picture

There is currently no support for this in D7.

marcos.518’s picture

Title: Apply coupon directly to cart item prices » Discounts Coupons nor working Google checkout
Version: 6.x-1.x-dev » 6.x-1.7
Assigned: Unassigned » marcos.518

Does anybody know if there is a patch for Discounts coupons 6.x-1.7? Coupons works juts fine until I apply it and the google checkout button tuns gray not letting me advance... Please let me know if other issue could guide me into this thank you.

wodenx’s picture

Version: 6.x-1.7 » 6.x-1.x-dev

As said in #13, you have to apply this patch to the dev snapshot (6.x-1.x-dev) - that probably has some bug fixes implemented since 1.7, so you might want to update to that anyway.

marcos.518’s picture

HI Wodenx,
I already upgraded into the 6.x-1.x-dev version of the uc_coupons module, an still not working, apparently this patch does not affect the “uc_coupon.admin.inc” file? Down here the results of trying to install the patch. Do you have any Idea about these results? May be I’m doing something wrong?
Thank you so much for your help.

[root@li231-162 uc_coupon]# patch -p0 -b < discount-product-prices-10.patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/uc_coupon.admin.inc b/uc_coupon.admin.inc
|index 05425e0..bcec177 100644
|--- a/uc_coupon.admin.inc
|+++ b/uc_coupon.admin.inc
--------------------------
File to patch: uc_coupon.admin.inc
patching file uc_coupon.admin.inc
can't find file to patch at input line 27
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/uc_coupon.module b/uc_coupon.module
|index 352f129..a725a17 100644
|--- a/uc_coupon.module
|+++ b/uc_coupon.module
--------------------------
File to patch: uc_coupon.module
patching file uc_coupon.module
Hunk #1 succeeded at 500 (offset 2 lines).
Hunk #2 succeeded at 621 (offset 2 lines).
Hunk #3 succeeded at 934 (offset 2 lines).
Hunk #4 succeeded at 1049 (offset 2 lines).
Hunk #5 succeeded at 1242 (offset 2 lines).
Hunk #6 succeeded at 1260 (offset 2 lines).
Hunk #7 succeeded at 1294 (offset 2 lines).

bjcone’s picture

I applied the patch from #10 and am still not able to submit GCO orders which contain coupons. I am using UC version 6.x-2.7. It looks like it is expecting the coupon to be a node with the "this product conforms to Google Checkout content policies" value set (gc_salable property).

It may be simplistic but it seems like this could be solved with a modification to the UC_Google_checkout module to also accept coupon line items (line 447 of uc_google_checkout.module).