Пример #1
0
 static function menu_cart(MenuItem $item)
 {
     $item->url = route('vanemart::cart');
     $item->classes[] = 'cart';
     $key = Cart::has() ? 'cart_filled' : 'cart';
     $item->caption = \Vane\Menu::caption($key);
     if (Cart::has()) {
         $sum = Cart::subtotal();
         $replaces = array('sumn' => Str::number($sum), 'summ' => Str::langNum('general.price', $sum), 'sumf' => Str::langNum('general.currency_full', $sum), 'sums' => Str::langNum('general.currency_short', $sum), 'count' => Str::langNum('general.goods', Cart::count()));
         $item->caption = Str::format($item->caption, $replaces);
         $item->hint = Str::format(\Vane\Menu::caption('cart_hint'), $replaces);
     }
 }
Пример #2
0
Event::listen(VANE_NS . 'checkout.old_user', function (User $user, array &$options) {
});
// Fired when an order is performed. Follows either checkout.reg_user or
// checkout.old_user events. $options are the same as of checkout.old_user.
Event::listen(VANE_NS . 'checkout.done', function (User $user, array &$options) {
    $orderInfo = function ($block, Order $order) {
        $response = \Vane\Block::execCustom($block, array('args' => $order->id, 'input' => array('code' => $order->password, 'grouped' => 0), 'prepare' => function ($block) {
            $block->user = false;
        }, 'response' => true, 'return' => 'response'));
        return $response->render();
    };
    $view = Current::expand('mail.checkout.user');
    Mail::sendTo($user->emailRecipient(), $view, array('user' => $user->to_array(), 'order' => $options['order']->to_array(), 'orderHTML' => $orderInfo('VaneMart::order@show', $options['order']), 'goodsHTML' => $orderInfo('VaneMart::order@goods', $options['order'])));
});
Event::listen(VANE_NS . 'checkout.done', function (User $user, array &$options) {
    Cart::clear();
});
/*-----------------------------------------------------------------------
| FILE BLOCK
|----------------------------------------------------------------------*/
// Fired when a file download has been requested. If $file's attributes were changed
// during event processing the model will be saved automatically.
// If it returns non-null it's considered an exceptional case (e.g. access problem)
// and returned without initiating the download by firing file.dl.response.
//
//* $path str - absolute local file system path to stored File data.
//
//= null, mixed override normal file serving (passed through to DoubleEdge)
Event::listen(VANE_NS . 'file.dl.before', function (&$path, File &$file, Block_File $block) {
    if (!is_file($path)) {
        Log::error_File("Missing stored data file [{$path}] of {$file}.");