Exemplo n.º 1
0
 /**
  * @param $cart - the cart object
  */
 protected function printCartJSON(EventgalleryLibraryCart $cart)
 {
     $jsonCart = array();
     foreach ($cart->getLineItems() as $lineitem) {
         /* @var $lineitem EventgalleryLibraryImagelineitem */
         $item = array('file' => $lineitem->getFileName(), 'folder' => $lineitem->getfolderName(), 'count' => $lineitem->getQuantity(), 'singleprice' => $lineitem->getSinglePrice(), 'price' => $lineitem->getPrice()->getAmount(), 'lineitemid' => $lineitem->getId(), 'typeid' => $lineitem->getImageType()->getId(), 'imagetag' => $lineitem->getMiniCartThumb());
         array_push($jsonCart, $item);
     }
     echo json_encode($jsonCart);
 }
Exemplo n.º 2
0
 /**
  * @param EventgalleryLibraryCart $cart
  * @return EventgalleryLibraryOrder
  */
 public function createOrder($cart)
 {
     $db = JFactory::getDBO();
     $data = $cart->_getInternalDataObject();
     $uuid = uniqid("", true);
     $uuid = base_convert($uuid, 16, 10);
     $query = $db->getQuery(true);
     $query->insert("#__eventgallery_order");
     $query->columns('id');
     $query->values($db->quote($uuid));
     $db->setQuery($query);
     $db->execute();
     $user = JFactory::getUser();
     $data['id'] = $uuid;
     if (!$user->guest) {
         $data['userid'] = $user->id;
     }
     /**
      * @var TableOrder $orderTable
      */
     $orderTable = $this->store($data, 'Order');
     /**
      * @var EventgalleryLibraryImagelineitem $lineitem
      * @var EventgalleryLibraryFactoryImagelineitem $imageLineItemFactory
      */
     $imageLineItemFactory = EventgalleryLibraryFactoryImagelineitem::getInstance();
     foreach ($cart->getLineItems() as $lineitem) {
         $imageLineItemFactory->copyLineItem($orderTable->id, $lineitem);
     }
     /**
      * @var EventgalleryLibraryServicelineitem $lineitem
      * @var EventgalleryLibraryFactoryServicelineitem $serviceLineItemFactory
      */
     $serviceLineItemFactory = EventgalleryLibraryFactoryServicelineitem::getInstance();
     foreach ($cart->getServiceLineItems() as $lineitem) {
         $serviceLineItemFactory->copyLineItem($orderTable->id, $lineitem);
     }
     /**
      * @var EventgalleryLibraryManagerOrderstatus $orderstatusMgr
      */
     $orderstatusMgr = EventgalleryLibraryManagerOrderstatus::getInstance();
     /**
      * @var EventgalleryLibraryOrder $order
      */
     $order = new EventgalleryLibraryOrder($orderTable->id);
     $order->setOrderStatus($orderstatusMgr->getDefaultOrderStatus(EventgalleryLibraryOrderstatus::TYPE_ORDER));
     $order->setPaymentStatus($orderstatusMgr->getDefaultOrderStatus(EventgalleryLibraryOrderstatus::TYPE_PAYMENT));
     $order->setShippingStatus($orderstatusMgr->getDefaultOrderStatus(EventgalleryLibraryOrderstatus::TYPE_SHIPPING));
     $order->setDocumentNumber(EventgalleryLibraryDatabaseSequence::generateNewId());
     return $order;
 }
Exemplo n.º 3
0
 function display($tpl = NULL)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->params = $app->getParams();
     /* @var EventgalleryLibraryManagerCart $cartMgr */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     $this->cart = $cartMgr->getCart();
     if ($this->cart->getLineItemsCount() == 0) {
         $this->setLayout("empty");
     }
     $pathway = $app->getPathWay();
     $pathway->addItem(JText::_('COM_EVENTGALLERY_CART_PATH'));
     // show a disabled message once the cart is not active
     if ($this->params->get('use_cart', 1) == 0) {
         $this->setLayout('disabled');
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
Exemplo n.º 4
0
 function display($tpl = null)
 {
     /**
      * @var JSite $app
      */
     $app = JFactory::getApplication();
     $this->state = $this->get('State');
     $this->params = $app->getParams();
     /* @var EventgalleryLibraryManagerCart $cartMgr */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     $this->cart = $cartMgr->getCart();
     // set the default view
     if ($this->getLayout() == 'default') {
         $this->setLayout('review');
     }
     // if the current layout is not confirm and some details are missing, display the change page.
     // if there are no items in the cart, go the the cart page.
     if ($this->getLayout() != 'confirm') {
         if ($this->cart->getLineItemsCount() == 0) {
             $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=cart", false));
         }
         if ($this->cart->getBillingAddress() == null || $this->cart->getShippingAddress() == null || $this->cart->getPaymentMethod() == null || $this->cart->getShippingMethod() == null) {
             $this->setLayout('change');
         }
     }
     if ($this->getLayout() == 'change') {
         $xmlPath = JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_eventgallery' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'forms' . DIRECTORY_SEPARATOR;
         $this->userdataform = JForm::getInstance('userdata', $xmlPath . 'userdata.xml');
         $this->userdataform->reset();
         $this->userdataform->bind(array('message' => $this->cart->getMessage(), 'email' => $this->cart->getEMail(), 'phone' => $this->cart->getPhone()));
         $this->userdataform->bind(JRequest::get('post'));
         $this->billingform = JForm::getInstance('billing', $xmlPath . 'billingaddress.xml');
         $this->billingform->reset();
         if ($this->cart->getBillingAddress() != null) {
             $this->billingform->bind($this->cart->getBillingAddress()->_getData('billing_'));
         }
         $this->billingform->bind(JRequest::get('post'));
         $this->shippingform = JForm::getInstance('shipping', $xmlPath . 'shippingaddress.xml');
         if ($this->cart->getShippingAddress() != null) {
             $this->shippingform->bind($this->cart->getShippingAddress()->_getData('shipping_'));
         }
         $this->shippingform->bind(JRequest::get('post'));
     }
     $pathway = $app->getPathWay();
     $pathway->addItem(JText::_('COM_EVENTGALLERY_CART_CHECKOUT_PATH'));
     $this->_prepareDocument();
     parent::display($tpl);
 }