Пример #1
0
 /**
  * Update cart content
  *
  * @access  public
  * @return  Response
  */
 protected function update_cart()
 {
     $items = \Cart::items();
     if (\Input::post() && $items) {
         try {
             $post = \Input::post();
             foreach ($items as $item) {
                 if (isset($post['quantity'][$item->uid()])) {
                     $item->setQuantity($post['quantity'][$item->uid()]);
                 }
             }
             if (isset($post['artwork_quantity'])) {
                 foreach ($post['artwork_quantity'] as $key => $value) {
                     if ($artwork = \Order\Model_Artwork::find_one_by_id($key)) {
                         $artwork->set(array('quantity' => $value));
                         $artwork->save();
                     }
                 }
             }
             \Messages::success('Cart successfully updated.');
         } catch (\Database_Exception $e) {
             // show errors
             \Messages::error('There was an error while trying to update cart.');
         }
     }
 }
Пример #2
0
 public function action_cost()
 {
     if (!$this->check_logged()) {
         \Messages::error('You must be logged in if you want to continue with your order.');
         \Response::redirect(\Uri::create('order/checkout/address'));
     }
     $items = \Cart::items();
     if (\Input::post() && $items) {
         $post = \Input::post();
         foreach ($items as $item) {
             if (isset($post['quantity'][$item->uid()])) {
                 $item->setQuantity($post['quantity'][$item->uid()]);
             }
         }
         if (isset($post['artwork_quantity'])) {
             foreach ($post['artwork_quantity'] as $key => $value) {
                 if ($artwork = \Order\Model_Artwork::find_one_by_id($key)) {
                     $artwork->quantity = $value;
                     $artwork->save();
                 }
             }
         }
     }
     $order = \Order\Model_Order::forge();
     $shipping_price = $order->shipping_price(null, null, true);
     \Theme::instance()->set_partial('content', $this->view_dir . 'cost')->set('items', $items, false)->set('credit_account', \Order\Model_Order::credit_account(null, \Cart::getTotal('price')), false)->set('user', \Sentry::user(), false)->set('shipping_price', $shipping_price);
 }