/**
 * Allow modules alter the rule object, with configuration specifc
 * to commerce discount.
 *
 * @param RulesPlugin $rule
 *   The rule configuration entity, passed by reference.
 * @param CommerceDiscount $commerce_discount
 *   The commerce discount entity.
 */
function hook_commerce_discount_rule_build($rule, $commerce_discount)
{
    if ($commerce_discount->name == 'foo') {
        $rule->action('drupal_message', array('message' => 'Discount FOO was applied.'));
    }
}
Beispiel #2
0
/**
 * Act on a rules configuration being inserted or updated.
 *
 * This hook is invoked before the rules configuration is saved to the
 * database.
 *
 * @param RulesPlugin $config
 *   The rules configuration that is being inserted or updated.
 */
function hook_rules_config_presave($config)
{
    if ($config->id && $config->module == 'yours') {
        // Add custom condition.
        $config->conditon();
    }
}