3. Tokens, Views and Rules integration - backdrop-contrib/uc_affiliate2 GitHub Wiki

Rules integration

Backdrop's version of UC Affiliate v2 provides Rules integration specifically for commissions (this is not the case with the current Drupal version!). Commissions can be accessed through Rules that have access to Ubercart orders.

Events

This module provides an affiliate-related new event: "Affiliate commissions being applied", that triggers when an order is completed and a commission is applied to an affiliate for that order. This event provides both, a Commission object, and the UC order entity, to the Rule.

Conditions

  • User has affiliate: this returns true if a user is linked to an affiliate. This condition requires a user entity.
  • Commission amount comparison: compares the earned commission amount to a specific amount. This condition requires a Commission object.
  • Check affiliate level: when a commission is applied, this condition can check the level of the affiliate for whom the order is generating a commission

Actions

  • Override the commission percentage: requires a Commission object and allows to use logic to change the commission percentage applied to the order

Full Rules

  • E-mail affiliate on new commission: this rule (disabled by default) sends an email to an affiliate whenever a commission is applied in their benefit. This Rule can be overridden to change, for example, the text of the email.

Views integration

  • Product commission structure. Accessible through views of Content (i.e. UC products)

The following are all accessible through Views of UC Orders

  • Commission affiliate ID
  • Order commission structure
  • Commission notes (these are added automatically by UC Affiliate v2 to indicate commissions applied for an order)

Tokens

UC Affiliate v2 provides several order commission tokens, accessible through chaining of uc_order tokens. These tokens also allow for chaining into users, for example, [uc_order:uc-affiliate2-commission:affiliate:name] will allow you to access the username of an affiliate who received a commission in a specific order.