Download & Extend

Commerce Coupon by product reference

This module helps you set up percentage coupons that only apply to specific products. It uses a multi-value entity reference field attached to the coupon to select which products will be discounted. If the field is left empty then the coupon will be valid for all products.

The module adds:

  1. A new condition for evaluating whether an order contains a product referenced by a coupon (commerce_couponprodref_order_has_referenced_product);
  2. A multi-value entity reference field linking coupons to products (field_commerce_couponprodref);
  3. A Rules component for applying percentage coupons to line items where they match the reference field (rules_commerce_couponprodref_apply_coupon_to_line_item_component);
  4. A new coupon validation rule that won't allow a coupon to be redeemed if it has a populated reference field that doesn't match any of the products in the cart (rules_commerce_couponprodref_validate_refererenced_products).

The future!

I understand that with Commerce Coupon 2.x and Commerce Discount this module won't be needed any more.

Installation & Use

  1. Enable the module as normal.
  2. Clear all caches.
  3. It's necessary to modify the percentage coupon pricing rule.
    1. Go to Configuration -> Workflow -> Rules and click edit for the rule Apply percentage coupons to product line item.
    2. Delete the looped action Apply a percentage coupon to a product line item.
    3. Add a new looped action rule: Apply coupon to line item (checking product reference).
    4. Select commerce-line-item for the line item and list-coupon for the coupon. (If you can't find list-coupon then it's possible you didn't try to add an action within the loop - make sure to click Add action under Operations for the loop.)
  4. The reference field is added automatically to the bundle commerce_coupon_pct (it can be removed). The field can be added to other coupon types if desired.

You should now be able to create new percentage coupons that reference products. If a customer tries to use a coupon that doesn't match any products in their cart, then there will be a validation failure. If a customer does have one or more valid products for that coupon, then all referenced products will be discounted appropriately.

Downloads

Recommended releases

Version Downloads Date Links
7.x-1.0-alpha1 tar.gz (10.41 KB) | zip (12.34 KB) 2012-Aug-29 Notes

Development releases

Version Downloads Date Links
7.x-1.x-dev tar.gz (10.37 KB) | zip (12.34 KB) 2013-Feb-16 Notes

Project Information


Maintainers for Commerce Coupon by product reference

  • AndyF - 8 commits
    last: 1 hour ago, first: 43 weeks ago

Issues for Commerce Coupon by product reference

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Statistics (2 years)
New issues
Open bugs
Participants
nobody click here