<?php /* @var $this \yii\web\View */ /* @var $content string */ use yii\helpers\Html; use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use app\assets\AppAsset; use app\models\Cart; AppAsset::register($this); $navItems[] = ['label' => 'Home', 'url' => ['/']]; if (Yii::$app->user->isGuest) { $navItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { $cart = Cart::getCurrentCart(); $cart->processCart(); $navItems[] = ['label' => 'Cart' . ($cart->quantity ? ' (' . $cart->quantity . ')' : ''), 'url' => ['/cart']]; $navItems[] = ['label' => 'My Account', 'url' => ['/account']]; $navItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->name . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]; } $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset;
public function actionSave() { $session = new Session(); $user = Yii::$app->user->identity; $cart = Cart::getCurrentCart(); $cart->processCart(); if ($cart->total > 0) { return $this->actionCharge(); } $cart->status = Cart::CART_SOLD; $cart->save(); $session->addSuccess(Yii::t('app', 'Congratulations, you\'ve completed your order!')); $cart_lines = []; foreach ($cart->items as $item) { $cart_lines[] = $item->ticket->group->event->name . ': ' . $item->ticket->name . ' x' . $item->quantity . ' @ ' . $item->ticket->ticket_price . ' each'; } $cart_details = implode("\n", $cart_lines); $email = new Email(); $email->to_name = $user->name; $email->to_email = $user->email; $email->subject = "Your Tixty Purchase"; $message = <<<EOT Hi {$user->name}!! You just bought {$cart->quantity} tickets for a total of {$cart->total} - details below. Thanks, Tixty --- {$cart_details} EOT; $email->body = nl2br($message); $email->save(); $email->send(); $email = new Email(); $email->to_name = "Tixty"; $email->to_email = \Yii::$app->params['adminEmail']; $email->subject = "Tixty Purchase #{$cart->id}"; $message = <<<EOT {$user->name} just bought {$cart->quantity} tickets for a total of {$cart->total} - details below. Tixty --- {$cart_details} EOT; $email->body = nl2br($message); $email->save(); $email->send(); return $this->redirect('index'); }