Ejemplo n.º 1
0
 function confirm()
 {
     //Generate a new basket item
     $Item = new OrderItem();
     $Basket = $this->_fetchBasket();
     $Title = array();
     foreach ($Basket['items'] as $Option) {
         if ($Option->type == 'Style') {
             $Item->image($Option->image);
         }
         $String = $Option->type . ': ' . $Option->title;
         if (isset($Option->variant)) {
             $String .= ' (' . $Option->variant . ')';
         }
         $Title[] = $String;
     }
     $Item->title('Custom Order');
     $Item->subtitle(implode($Title, ' & '));
     $Item->source('custom:' . substr(md5(time()), 0, 6));
     $Item->quantity(1);
     $Item->hidden(json_encode($this->basket));
     $Item->price($Basket['total']);
     $Item->addToOrder();
     $this->clear();
     redirect('/checkout/');
 }
Ejemplo n.º 2
0
 function fromOrderItem(OrderItem $Item)
 {
     $this->title = $Item->title();
     $this->subtitle = $Item->subtitle();
     $this->quantity = $Item->quantity();
     $this->hidden = $Item->hidden();
     $this->price = $Item->price();
     $this->image = $Item->image();
     list($Source, $ID) = $Item->source();
     if ($Source == 'shop') {
         $this->storeitem = $ID;
     }
 }
Ejemplo n.º 3
0
 function addtocart($ProductID)
 {
     //Generate a new basket item
     $Item = new OrderItem();
     $Product = new mStoreItem($ProductID);
     $Item->title($Product->title);
     $Item->source('shop:' . $Product->id());
     $Item->subtitle($Product->description);
     $Item->quantity(1);
     $Item->image($Product->main_image()->filename);
     $Item->hidden(json_encode($Product->_data));
     $Item->price($Product->price);
     $Item->addToOrder();
     redirect('/checkout/');
 }
Ejemplo n.º 4
0
 function addToOrder(OrderItem $Item)
 {
     //Check the item doesnt exist?
     $Exist = false;
     foreach ($this->items as &$Existing) {
         if ($Existing->source() == $Item->source()) {
             $Exist = true;
             $Existing->quantity($Existing->quantity() + $Item->quantity());
         }
     }
     if (!$Exist) {
         $this->items[] = $Item;
     }
     $this->_saveOrder();
 }