I'm working on a new system (including a custom Coupon type) that allows users to "gift" products to each other. Actually, the first attempt is for admins to do this, for example to give away digital products as rewards for fulfilling tasks (or as Kickstarter rewards).
However, it appears that commerce_order appears in various places, including Rules Conditions and functions such as commerce_coupon_current_user_may_redeem() and commerce_coupon_evaluate_conditions(). This makes it impossible for customers to redeem a coupon anywhere outside of a checkout/order context, thereby the above scenario of "redeeming a coupon for a free product" a non-existent one. (NOTE: this is different from the "Free add-on products" discount wherein a customer can add a product at no cost to an in-progress order.)
I think the best solution, then, is to do the following:
1. Create a new property of hook_commerce_coupon_type_info() called order_optional which custom coupon type providers can set to TRUE.
2. In the default condition rule builder and other Rules methods, wrap references to commerce_order within a condition to check for the above property;
3. ...
4. Profit?
Happy to discuss this further but it seems like a fairly straightforward addition, and with the new property in place, hopefully it would not break existing sites.
Comments
Comment #2
torgospizzaComment #3
torgospizzaThe other option I thought of, and have used elsewhere in a custom implementation, was to simply create a dummy order, and then if we want to issue a gift product, it's trivial to create it as a new line item and set the Order Status to Completed. This might actually make even more sense to go this route, because having an order for a free product allows site administrators / financing people to better audit where the free stuff is going. I'll rethink how I'm doing this and see if that's better.