Пример #1
0
 function save_new_order_item()
 {
     //eDebug($this->params,true);
     //check for multiple product adding
     $order = new order($this->params['orderid']);
     if (isset($this->params['prod-quantity'])) {
         //we are adding multiple children, so we approach a bit different
         //we'll send over the product_id of the parent, along with id's and quantities of children we're adding
         foreach ($this->params['prod-quantity'] as $qkey => &$quantity) {
             if (in_array($qkey, $this->params['prod-check'])) {
                 $this->params['children'][$qkey] = $quantity;
             }
             if (isset($child)) {
                 $this->params['product_id'] = $child->parent_id;
             }
         }
     }
     $product = new $this->params['product_type']($this->params['product_id'], true, true);
     //need true here?
     if ($product->addToCart($this->params, $this->params['orderid'])) {
         $order->refresh();
         $order->calculateGrandTotal();
         $order->save();
         flashAndFlow('message', 'Product added to order.');
         redirect_to(array('controller' => 'order', 'action' => 'show', 'id' => $this->params['orderid']));
     }
     /*else
       {
           expHistory::back();
       }*/
 }