3

I need to create an custom event for an action to be triggered in the Rules module.

Custom event is after completing the checkout process the page will be redirected to confirmation page. I need to trigger an action if the page is redirected to the confirmation page.

I need to check if the user has on the confirmation page like /payment-confirmation then i need to trigger an action.

1

Let's assume that the Rules action that you want to trigger is to just set a Drupal message like "Rules action related to payment confirmation". But this action should only be triggered when "Viewing the content" located at your confirmation page, which has a path like "/payment-confirmation".

To get this to work, use the rule below (in Rules export format, just import it in your site and check the results of it):

{ "rules_extra_action_about_payment_confirmation" : {
    "LABEL" : "Extra action about payment confirmation",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_view" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "site:current-page:path" ], "value" : "/payment-confirmation" } }
    ],
    "DO" : [ { "drupal_message" : { "message" : "Rules action related to payment confirmation" } } ]
  }
}

The rule above should be close to what you're looking for, except from these further refinements:

  • Replace the rules Action by your own rules "action" (which you didn't specify).
  • If you want your Rules Action to be performed before your confirmation page is actually shown, then replace the Rules Event (= "ON" : { "node_view" : [] },) with "ON" : { "init" : [] }, (= "Drupal is initializing").
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.