Difference between revisions of "How to redirect user to different thanks page after payment"

From aMember Pro Documentation
Jump to: navigation, search
Line 6: Line 6:
 
<source>
 
<source>
 
<?php
 
<?php
        Am_Di::getInstance()->hook->add(Am_Event::THANKS_PAGE, 'onThanksPage');
+
Am_Di::getInstance()->hook->add(Am_Event::THANKS_PAGE, 'onThanksPage');
        function onThanksPage(Am_Event $event){
+
function onThanksPage(Am_Event $event){
            /* @var $di Am_Di */   
+
    /* @var $di Am_Di */   
            $di = Am_Di::getInstance();
+
    $di = Am_Di::getInstance();
            /* @var $invoice Invoice */  
+
    /* @var $invoice Invoice */  
            $invoice = $event->getInvoice();
+
    $invoice = $event->getInvoice();
            /* @var $controller ThanksController */  
+
    /* @var $controller ThanksController */  
            $controller = $event->getController();
+
    $controller = $event->getController();
  
            $controller->redirectLocation('/url/where/user/should/be/redirected');
+
    $controller->redirectLocation('/url/where/user/should/be/redirected');
        }
+
}
?>
+
 
</source>
 
</source>

Revision as of 03:46, 9 August 2013

You can use our thanks-redirect plugin to do it. This plugin allow you to set up custom redirect url for each product in admin interface.

In case you need some more complex logic you can use the following approach:

Add this code to site.php file:

<?php
Am_Di::getInstance()->hook->add(Am_Event::THANKS_PAGE, 'onThanksPage');
function onThanksPage(Am_Event $event){
    /* @var $di Am_Di */  
    $di = Am_Di::getInstance();
    /* @var $invoice Invoice */ 
    $invoice = $event->getInvoice();
    /* @var $controller ThanksController */ 
    $controller = $event->getController();
 
    $controller->redirectLocation('/url/where/user/should/be/redirected');
}