Hi, forgive me if this issue is solved anywhere, I haven't found anything.

I've created a coupon for a product, in fact I've configured it as an automatic coupon with rules and it works perfectly.

The problem is that I need to display the coupon information in a view and in the product page, at least something as "this product has a coupon".

Thanks in advance, Diego.

Comments

wodenx’s picture

Category: support » feature

This is not currently possible - at least not automatically. The right way to implement this would be to refactor so that coupon restrictions are saved in their own table and expose that table to views (they are currently serialized into the main coupon table along wth a lot of other data, so it's difficult to create relations). That's a fairly extensive rewrite which I can't undertake right now.

You could also write a custom sub-module that does this just for product restrictions by implementing hook_uc_coupon_save().

wodenx’s picture

Component: uc_coupon_workflow » Code
dbrouard’s picture

Ok, thank you!

wodenx’s picture

I've just finished porting some views support from uc_coupon_tracking into the D7 version of uc_coupon - and I think there is a way to accomplish what you're after. Look at uc_coupon_handler_argument_product_type.inc (only in the DEV branch) - this uses a mysql regexp to search for product types in the serialized data array. You could probably do something similar with actual product ids. Note, however, that this would only list coupons which have specifically listed product id's - and you'd have to do something special to handle the case where certain product types are *excluded*.