Posted by tizzo on June 3, 2009 at 8:30pm
| Project: | Ubercart Discount Coupons |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
This post is closely related to the paypal express checkout issue. uc_coupon currently does not work with Google Checkout. This patch solves two problems, first it gets uc_coupon to work with Google Checkout and second it causes the cart pane to display the new pricing when a coupon is applied.
I have not tested it with paypal express or ubercart's normal checkout pane but I think that they should continue to work as they did previously.
Should I still create an issue for updating the cart when using the coupon form on that page? The way this patch is implemented it kills two birds and can't easily be separated into two different patches.
Comments
#1
somehow didn't get the patch posted...
#2
Updating status to needs review
#3
This patch does not take into account any coupon restrictions as long as there is at least one valid product in the cart - the discount is applied to all products in the cart, even if a product, SKU or term restriction was set so the discount should only apply to a subset of cart items.
Also, if another payment method is used that goes through the standard checkout, a coupon can now be applied twice - once in the cart, where the product prices are modified directly, and again in the checkout, where the coupon is applied as a line item, to the items that were already discounted in the cart. This could be partially worked around by either creating an options page to enable this functionality or simply testing for Google Checkout as an available payment method, but we also need to support stores that want to offer both Google Checkout and other payment methods. while not allowing coupons to be applied twice.
#4
Yeah that is an issue. Also I just realized that this version will also deduct the total coupon amount from each of the products if the value is a whole dollar amount. I attached a quick fix patch for that.
At the moment this does what we need it to do (we're only allowing google checkout). If anyone else wants to add settings for that it would be great, if not I'll see if I can get to it soon.
#5
subscribing
#6
the above patches failed for me. this is the same code, just updated against current head.
i don't think this code is complete and should pretty much be considered a hack to get uc_coupons to work with google checkout
#7
Hi Guys
I am not a very good Drupaler but please can someone tell me how to use patch I have no clue what to do here
thanks
#8
Same boat here. I know though how to manually read the pluses and minuses to update, but the above is for a dev version. This module is at 6.x-1.3 now. Does anyone have any plans to get this into this module, so a patch is not needed?
#9
FYI: since no one seems to have put this into production yet, my comment here is only that one will need to comment out one of the extra 'The coupon has been applied to your order.' I commented out the first of the 2 from here in patch 2:
+ $_SESSION['uc_coupon'] = $code;
+ drupal_set_message(t('The coupon has been applied to your order.'));
+ $_SESSION['uc_coupon_valid'] = $coupon->amount;
+ $_SESSION['uc_coupon_value'] = $coupon->value;
+ $_SESSION['uc_coupon_type'] = $coupon->type;
+ $coupon->message = t('The coupon has been applied to your order.');
+ drupal_set_message($coupon->message);
+ }
+ }
+ }
+
#10
here is an updated patched, cleaned up some of the code, removed the duplicate drupal_set_message, and now the message is more descriptive, adding the title of the coupon to drupal_set_message.
#11
oops, forgot to attach the patch
#12
Ok, it seems this approach is still fundamentally flawed with some bugs. I've spent the day digging thru the code, and the way this module is designed I don't think there is going to be a solid way to make this work with out over hauling the way the module was designed or resorting to hacky fixes. From what i have gathered, all of the discounting happens leveraging order hooks and transversing the cart and doing the math against the item price.
If the module was reworked to have uc_coupon_validate() validate a coupon against individual nodes and the price was adjusted using a price handler it could work. The validation could most likely happen in hook_cart_item, and the coupon info tacked onto the $item->data array. With the data residing within the item, the price can then be altered at hook_uc_price_handler(). This would make a cleaner approach to handling coupon discounts at the cart level. It would also solve #663502: work with uc_discounts since right now the module is not taking any price alters into consideration. and solve #509932: Coupon doesn't change price in cart. It would possibly solve a few other bugs lingering around and possibly set the module up for some requested features (ie multiple coupons per transaction).
However, this is a pretty drastic overhaul to the module, and would probably warrant a 2.x release instead of being roled into 1 if it were to be considered as an actual release. I'd be curious to get the opinion of the maintainers in regards to this issue and proposed solution.
#13
Marking this as a duplicate of #629176: Apply coupon directly to cart item prices as I think implementing that will finally solve this issue too.
#15
Can anyone upload patched uc_coupon.module file to somewhere...?
am new at drupal and have no idea about patching or git patching ok - means delete line + means add line but there is no exect line as patch says..
for ex:
@@ -920,7 +920,9 @@ function uc_coupon_validate($code) { // first of all i dont know the meaning of @@ -920,7 +920,9 @@
ok i found function uc_coupon_validate but it has no ($code) its ($code, $order = NULL, $account = NULL) and the line # is 455 and no $result->code = $code; under it... please some one explane or give patched uc_coupone.module...
Thank you already now Best regards...
#16
The patches in this thread are severely out of date and shouldn't be used. However, I've just updated a patch at #629176: Apply coupon directly to cart item prices, which, as noted in #13, addresses the same issue. Please try it out and report any problems back in that thread.
As to applying patches - doing it manually is laborious and error-prone. On *nix machince (including max/osx) just download the patch file to your computer, cd to the module folder (eg .../sites/all/modules/uc_coupon) and then enter
patch -p1 < /path/to/patch-fileOn windows, have a look at this manual page.