Example #1
0
 private function createOrder()
 {
     foreach ($this->cart['items'] as &$cartItem) {
         $cartItem->data = ['product_id' => $cartItem->product->id, 'child_id' => $cartItem->child_id, 'date_start' => $cartItem->plugins->booking->date_start, 'date_end' => $cartItem->plugins->booking->date_end];
     }
     $this->order = Sp4kAppsOrderApp::getInstance(new Registry(['account_id' => $this->account->id, 'items' => $this->cart['items'], 'total' => $this->cart['totals']['cost_now']]))->getItem()->update();
 }
Example #2
0
 public function execute()
 {
     $this->item = Sp4kAppsOrderApp::getInstance(new Joomla\Registry\Registry($this->state->toObject()))->getItem();
     foreach ($this->item->items as &$line_item) {
         foreach (json_decode($this->item->items[0]->product->config) as $index => $config) {
             $configModelClass = 'Sp4kModulesOrderModelsPlugins' . ucfirst($index) . 'Plg';
             if (class_exists($configModelClass)) {
                 $pluginClass = $configModelClass::getInstance(new Registry($config), $line_item);
             }
         }
     }
 }
Example #3
0
 protected function execute()
 {
     if ($this->state->get('paging', false)) {
         $limit = $this->state->get('limit');
         $filters = $this->state->get('filters');
         $count = $this->state->get('count', false);
         $appState = new Joomla\Registry\Registry(['limit' => $limit, 'count' => $count, 'filters' => $filters, 'joins' => $this->state->get('joins', false)]);
         /** @var Sp4kAppsRegistrationApp $registrationApp */
         $registrationApp = Sp4kAppsOrderApp::getInstance($appState);
         $appCollection = $registrationApp->getCollection();
         $this->count = $appCollection->count;
         $this->items = $appCollection->items;
     } else {
         $this->items = Sp4kAppsOrderApp::getInstance(new Joomla\Registry\Registry($this->state->toObject()))->getItems();
     }
 }
Example #4
0
 public function execute()
 {
     $cartSession = JFactory::getSession();
     $cart = ($cart = $cartSession->get('sp4k_cart')) ? $cart : [];
     $cartTotal = 0;
     if (count($cart) > 0) {
         //foreach cart item build the line item for display;
         $cartApp = Sp4kAppsCartApp::getInstance(new Registry($cart));
         $cart_items = $cartApp->getItems();
         foreach ($cart_items as $item) {
             $cartTotal += $item->total;
         }
     }
     $orderData = new stdClass();
     $orderData->total = 0;
     $orderData->created = time();
     $orderData->createdby = JFactory::getUser()->id;
     foreach ($cart_items as $type => $cart_item) {
         $orderItem = new stdClass();
         $orderItem->type = $type;
         $orderItem->mainline = $cart_item->mainline;
         $orderItem->sublines = $cart_item->sublines;
         $orderItem->total = $cart_item->total;
         $orderData->total += $orderItem->total;
         $orderData->cart[$type][] = $orderItem;
     }
     $orderData->cart = json_encode($orderData->cart);
     $order = Sp4kAppsOrderApp::getInstance(new Registry($orderData))->getItem()->update();
     $this->state->set('order_id', $order->id);
     $paymentData = new stdClass();
     $paymentData->amount = $cartTotal;
     /** @var Sp4kAppsPaymentItem $payment */
     $payment = Sp4kAppsPaymentApp::getInstance(new Registry($this->state->toObject()))->getItem()->charge();
     if ($this->error = $payment->getError()) {
         $order->status = 0;
     } else {
         $order->status = '1';
         $order->payment_id = $payment->id;
     }
     $order->update();
     return $this;
 }
Example #5
0
 public function execute()
 {
     $app = new Sp4kAppsAccountApp(new Registry($this->state->toObject()));
     $this->item = $app->getItem();
     $this->id = $this->item->id;
     $this->created = $this->item->created;
     $accountFilter = ['filters' => ['account_id' => $this->id]];
     if ($this->item->id != null) {
         $this->item->parents = Sp4kAppsParentApp::getInstance(new Registry($accountFilter))->getItems();
         foreach ($this->item->parents as &$parent) {
             $juser = JFactory::getuser($parent->juser_id);
             $parent->name = $juser->name;
             $parent->email = $juser->email;
         }
         $this->item->children = Sp4kAppsChildApp::getInstance(new Registry($accountFilter))->getItems();
         foreach ($this->item->children as $child) {
             $this->item->registrations = $this->item->registrations + Sp4kAppsRegistrationApp::getInstance(new Registry(['filters' => ['child_id' => $child->id]]))->getItems();
         }
         $this->item->subscriptions = Sp4kAppsSubscriptionApp::getInstance(new Registry($accountFilter))->getItems();
         $this->item->orders = Sp4kAppsOrderApp::getInstance(new Registry($accountFilter))->getItems();
     }
 }
Example #6
0
 private function createOrder()
 {
     $this->order = Sp4kAppsOrderApp::getInstance(new Registry($this->cart))->getItem()->update();
 }
Example #7
0
 public function getItems()
 {
     /** @var Sp4kAppsOrderApp $app */
     $app = Sp4kAppsOrderApp::getInstance(new Registry($this->state->toObject()));
     return $app->getItems();
 }