Ejemplo n.º 1
0
 function _onThanksPage(Am_Event $event)
 {
     /* @var $invoice Invoice */
     $invoice = $event->getInvoice();
     /* @var $controller ThanksController */
     $controller = $event->getController();
     if (!$invoice || !$invoice->tm_started) {
         return;
     }
     // invoice is not yet paid
     $this->getDi()->blocks->add(new Am_Block('thanks/success', 'Parent Invoices', 'oto-parents', $this, array($this, 'renderParentInvoices')));
     // find first matching upsell
     $oto = $this->getDi()->otoTable->findUpsell($invoice->getProducts());
     if ($controller->getRequest()->get('oto') == 'no') {
         $oto = $this->getDi()->otoTable->findDownsell($invoice->data()->get(self::LAST_OTO_SHOWN));
     }
     if (!$oto) {
         return;
     }
     $event->stop();
     if ($controller->getRequest()->get('oto') == 'yes') {
         return $this->yesOto($controller, $invoice, $this->getDi()->otoTable->load($invoice->data()->get(self::LAST_OTO_SHOWN)));
     }
     $invoice->data()->set(self::LAST_OTO_SHOWN, $oto->pk())->update();
     $html = $oto->render();
     $controller->getResponse()->setBody($html);
     throw new Am_Exception_Redirect();
 }
Ejemplo n.º 2
0
 function onThanksPage(Am_Event $event)
 {
     if (!$event->getInvoice()) {
         return;
     }
     $url = null;
     foreach ($event->getInvoice()->getProducts() as $pr) {
         if ($url = $pr->data()->get('thanks_redirect_url')) {
             break;
         }
     }
     $t = new Am_SimpleTemplate();
     $t->assign('invoice', $event->getInvoice());
     $t->assign('user', $event->getInvoice()->getUser());
     $url = $t->render($url);
     if ($url) {
         $event->getController()->redirectLocation($url);
     }
 }
Ejemplo n.º 3
0
 function onInitControllerPages(Am_Event $event)
 {
     if ($event->getController() instanceof AdminContentController) {
         $event->getController()->addPage('Am_Grid_Editable_Newsletter', 'newsletters', 'Newsletters');
     }
 }