custom thank you page per product?

Discussion in 'aMember Pro v.4' started by customcodegeek, Feb 10, 2012.

  1. customcodegeek

    customcodegeek Member

    Joined:
    Feb 10, 2012
    Messages:
    40
    I would like to return a user to a custom one time offer thanks page for a particular product after paying by paypal. Is it possible to set the return url on a per product basis?

    alternatively, I have created a new payment system plugin based on the paypal plugin and added a custom brick to allow admin to enter a return url in the forms editor. In the new plugin, I change the return url to the one entered in the custom brick.

    Will returning back to a page that is not the default return url cause a problem?
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    For PayPal return URL does not matter.

    If you are developing custom code, use the following sample to run custom actions on thanks page:
    application/default/plugins/misc/customthanks.php

    PHP:
    <?php
    class Am_Plugin_Customthanks extends Am_Plugin
    {
          
    // this method will be called before rendering "thanks" page
          
    function onThanksPage(Am_Event $event)
          {
              
    $controller $event->getController(); // ThanksController instance
                
    $controller->view->customVar "XXX"// you can use $customVar in thanks.phtml template
                //
                
    $invoice $event->getInvoice(); // Invoice instance OR NULL (!)
                
    if (!$invioce) return;
                foreach (
    $invoice->getItems() as $item)
                {
                      
    /* @var $item InvoiceItem */
                      
    if ($item->item_id == 123)
                            
    $controller->getResponse()->setRedirect('/custom/url/for/product#123');
                }
          }
    }
  3. customcodegeek

    customcodegeek Member

    Joined:
    Feb 10, 2012
    Messages:
    40
    that's wonderful, thanks Alex I'll give that a go.

    will there be an option in the future to set a return url on a per product basis?
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Nice idea, we will add it to the todo list.
  5. bwj292

    bwj292 New Member

    Joined:
    Apr 21, 2008
    Messages:
    17
    Hi Alex,

    That's perfect above, just what I've been looking for.

    I've just implemented this but no matter which product I purchase it always redirects back to the OTO custom thank you page I've set up. I want it to just go back if product ID = 4.

    Here's my code. Maybe it's something I've not set up correctly?

    Thank you for your help

    PHP:
    <?php
    class Am_Plugin_Customthanks extends Am_Plugin
    {
          
    // this method will be called before rendering "thanks" page
          
    function onThanksPage(Am_Event $event)
          {
              
    $controller $event->getController(); // ThanksController instance
                
    $controller->view->customVar "XXX"// you can use $customVar in thanks.phtml template
                //
                
    $invoice $event->getInvoice(); // Invoice instance OR NULL (!)
                
    if (!$invioce) return;
                foreach (
    $invoice->getItems() as $item)
                {
                      
    /* @var $item InvoiceItem */
                      
    if ($item->item_id == 4)
                            
    $controller->getResponse()->setRedirect('/members/application/default/themes/orion/thanks.phtml');
                }
          }
    }
  6. fmagusto

    fmagusto Guest

  7. bwj292

    bwj292 New Member

    Joined:
    Apr 21, 2008
    Messages:
    17
    Friendly bump :), would like to get this custom thank you page working.
  8. customcodegeek

    customcodegeek Member

    Joined:
    Feb 10, 2012
    Messages:
    40
  9. bwj292

    bwj292 New Member

    Joined:
    Apr 21, 2008
    Messages:
    17

Share This Page