Skip to content

Coupon

A coupon is a unique string that can be appended to any URL when visiting the site. Currently, coupons make use of ?c= query parameter. A coupon code appended to the URL may look like this:

https://www.interaction-design.org/join?c=new15j61n

A coupon allows visitors, who are using that specific URL, to redeem an offer connected to it. For example, they could get a 20% discount when signing up for an individual membership. Coupons are not limited to guests though. Registered members can also take advantage of coupons on various checkout flows.

Coupon Finder

Coupon Finder is a service class that is responsible for finding a coupon by its code. The service class is described by the CouponFinder contract, which currently has only one implementation: SessionCouponFinder. SessionCouponFinder is capable of extracting a coupon code from a request and storing it in the visitor’s session.

Coupon Middleware

The web middleware group includes CouponMiddleware, which is responsible for detecting and storing the information about the coupon code in the visitor’s session. The middleware is applied to all routes. It is sufficient to visit a URL with a coupon code appended to it only once and the platform will “remember” the coupon code from that point onward.

Creating Coupons

Coupons can be created on Nova.

Coupon attributes:

  • Code: An unique code that will be used as query parameter
  • Name: The text that will be displayed during checkout (on checkout form) and on invoice (as a discount under invoice line)
  • Payment Flow: The payment flow the coupon will be used on
  • Discount: The discount % that will be used to calculate discount value
  • Start Date: The starting date from which the coupon will be valid
  • End Date: The ending date until which the coupon will be valid
  • Is Enabled: A flag to enable/disable the coupon

Active Coupons

For the Coupon to be active it needs to be enabled and the current date must be between the start_date and end_date. To check if a Coupon is currently active you can make use of $coupon->isActive() method. There is also an active scope available.

php
Coupon::query()->active()->count(); // Count active coupons

Troubleshooting

Question: Why is my coupon not working?

Answer: Please make sure the coupon is active and is not soft-deleted. Furthermore, please remember that there may be multiple ways a visitor can receive a discount at IxDF, coupons are just one of them. For example the referral program has higher priority than coupons. Please review discount priority in the Campaign module documentation.