Validate coupon per product
alonpeer - June 23, 2009 - 14:27
| Project: | Ubercart Discount Coupons |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
I had a requirement of validating a given coupon can be used with a given product node, so I added the attached code.
I think this can be useful for others that need to use the coupon module and extend it.
| Attachment | Size |
|---|---|
| uc_coupon_product_validate.patch | 1.04 KB |

#1
What is a use case for this, where do you call this function from?
Also how does this work? I haven't applied this patch but it seems If the product in question isn't in the cart then uc_coupon_validate() will return FALSE. Also this function will return FALSE if the product being tested isn't specifically listed in the "Applicable products" section, but it might match by taxonomy or product class instead.
#2
You're right, I haven't noticed all of the new features in the current version, so my patch is broken.
This patch is part of a whole solution for my client's website, where they need their users to be able to apply a coupon per product before the product is added to the cart and not on the checkout coupon pane. So I need to be able to validate this coupon's usage before the item is added.
The current implementation of uc_coupon for coupon per product doesn't solve my whole problem.
I guess I need a new approach to this problem.