Example #1
0
 /**
  * removes an item from the cart
  */
 public function removeFromCart()
 {
     $lineitemid = JRequest::getString('lineitemid', NULL);
     /* @var EventgalleryLibraryManagerCart $cartMgr */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     $cart = $cartMgr->getCart();
     $cart->deleteLineItem($lineitemid);
     $cartMgr->calculateCart();
     $this->printCartJSON($cart);
 }
Example #2
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();
     parent::display($tpl);
 }
Example #3
0
 /**
  * updates the cart
  */
 public function updateCart()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     /* @var EventgalleryLibraryManagerCart $cartMgr */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     $cartMgr->updateLineItems();
     $cartMgr->calculateCart();
     $continue = JRequest::getString('continue', NULL);
     if ($continue == NULL) {
         $this->setRedirect(JRoute::_("index.php?option=com_eventgallery&view=cart"));
     } else {
         $this->setRedirect(JRoute::_("index.php?option=com_eventgallery&view=checkout"));
     }
 }
Example #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);
 }
Example #5
0
 public function testDeleteItem()
 {
     $controller = new EventgalleryControllerRest();
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $_SERVER['HTTP_HOST'] = 'localhost';
     /**
      * @var EventgalleryLibraryManagerCart $cartMgr
      */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     // CREATE
     $cart = $cartMgr->getCart();
     $this->assertNotEmpty($cart->getLineItems());
     $lineitems = $cart->getLineItems();
     /**
      * @var EventgalleryLibraryLineitem $lineitem
      */
     $lineitem = $lineitems[0];
     JRequest::setVar('lineitemid', $lineitem->getId());
     $controller->removeFromCart();
     $this->assertEmpty($cart->getLineItems());
 }
Example #6
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);
 }
Example #7
0
 public function testMethodes()
 {
     /**
      * @var EventgalleryLibraryManagerCart $cartMgr
      */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     // CREATE
     $cart = $cartMgr->getCart();
     $this->assertEmpty($cart->getLineItems());
     $cart->addItem("test", "A_001_2013-03-17_IMG_1294.jpg", "1");
     $this->assertNotEmpty($cart->getLineItems());
     /**
      * @var EventgalleryLibraryManagerShipping $shippingMgr
      */
     $shippingMgr = EventgalleryLibraryManagerShipping::getInstance();
     $methods = $shippingMgr->getMethods();
     foreach ($methods as $method) {
         /**
          * @var EventgalleryLibraryInterfaceMethod $method
          */
         $method->isEligible($cart);
     }
     /**
      * @var EventgalleryLibraryManagerPayment $paymentMgr
      */
     $paymentMgr = EventgalleryLibraryManagerPayment::getInstance();
     $methods = $paymentMgr->getMethods();
     foreach ($methods as $method) {
         /**
          * @var EventgalleryLibraryInterfaceMethod $method
          */
         $method->isEligible($cart);
     }
     /**
      * @var EventgalleryLibraryManagerSurcharge $surchargeMgr
      */
     $surchargeMgr = EventgalleryLibraryManagerSurcharge::getInstance();
     $methods = $surchargeMgr->getMethods();
     foreach ($methods as $method) {
         /**
          * @var EventgalleryLibraryInterfaceMethod $method
          */
         $method->isEligible($cart);
     }
 }
Example #8
0
 public function createOrder()
 {
     // switch to the change page.
     $continue = JRequest::getString('continue', null);
     if ($continue == null) {
         $this->setRedirect(JRoute::_("index.php?option=com_eventgallery&view=checkout&task=change"));
         return;
     }
     // Check for request forgeries.
     JRequest::checkToken();
     /* @var EventgalleryLibraryManagerCart $cartMgr */
     $cartMgr = EventgalleryLibraryManagerCart::getInstance();
     $cartMgr->calculateCart();
     $cart = $cartMgr->getCart();
     // if the cart is empty
     if ($cart->getLineItemsCount() == 0) {
         $this->setRedirect(JRoute::_("index.php?option=com_eventgallery&view=cart"));
         return;
     }
     /* create order*/
     $orderMgr = new EventgalleryLibraryManagerOrder();
     #$order = $cart;
     $order = $orderMgr->createOrder($cart);
     /* send mail */
     $send = $this->_sendOrderConfirmationMail($order);
     $orderMgr->processOnOrderSubmit($order);
     if ($send !== true) {
         $msg = JText::_('COM_EVENTGALLERY_CART_CHECKOUT_ORDER_FAILED') . ' (' . $send . ')';
     } else {
         $msg = NULL;
     }
     $this->setRedirect(JRoute::_("index.php?option=com_eventgallery&view=checkout&task=confirm"), $msg, 'info');
 }