Example #1
0
 /**
  * Get current amount from cart via ajax to display in realtime
  */
 public function ajaxAmountAction()
 {
     Enlight()->Plugins()->Controller()->Json()->setPadding();
     $this->View()->sBasketQuantity = $this->basket->sCountBasket();
     $amount = $this->basket->sGetAmount();
     $this->View()->sBasketAmount = empty($amount) ? 0 : array_shift($amount);
 }
Example #2
0
 /**
  * Get current amount from cart via ajax to display in realtime
  */
 public function ajaxAmountAction()
 {
     Enlight()->Plugins()->Controller()->Json()->setPadding();
     $this->View()->sBasketQuantity = $this->basket->sCountBasket();
     $amount = $this->basket->sGetAmount();
     $quantity = $this->basket->sCountBasket();
     $this->View()->sBasketQuantity = $quantity;
     $this->View()->sBasketAmount = empty($amount) ? 0 : array_shift($amount);
     if (Shopware()->Shop()->getTemplate()->getVersion() >= 3) {
         $this->Front()->Plugins()->ViewRenderer()->setNoRender();
         $this->Response()->setBody(json_encode(['amount' => Shopware()->Template()->fetch('frontend/checkout/ajax_amount.tpl'), 'quantity' => $quantity]));
     }
 }
Example #3
-1
 /**
  * @covers sBasket::sUpdateArticle
  */
 public function testsUpdateArticle()
 {
     // Null args, false result
     $this->assertFalse($this->module->sUpdateArticle(null, null));
     $this->module->sSYSTEM->sSESSION_ID = uniqid();
     $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID);
     // Get random article
     $randomArticle = $this->db->fetchRow('SELECT detail.articleID, detail.ordernumber
         FROM s_articles_details detail
         INNER JOIN s_articles article
           ON article.id = detail.articleID
         WHERE detail.active = 1
         ORDER BY RAND() LIMIT 1');
     $this->db->insert('s_order_basket', array('price' => 0.01, 'quantity' => 1, 'sessionID' => $this->session->get('sessionId'), 'ordernumber' => $randomArticle['ordernumber'], 'articleID' => $randomArticle['articleID']));
     $basketId = $this->db->lastInsertId();
     // Store previous amount
     $previousAmount = $this->module->sGetAmount();
     $this->assertEquals(array('totalAmount' => 0.01), $previousAmount);
     // Update the article, prices are recalculated
     $this->assertNull($this->module->sUpdateArticle($basketId, 1));
     $oneAmount = $this->module->sGetAmount();
     $this->assertGreaterThan($previousAmount['totalAmount'], $oneAmount['totalAmount']);
     // Update from 1 to 2, we should get a more expensive cart
     $this->assertNull($this->module->sUpdateArticle($basketId, 2));
     $twoAmount = $this->module->sGetAmount();
     $this->assertGreaterThanOrEqual($oneAmount['totalAmount'], $twoAmount['totalAmount']);
     $this->assertLessThanOrEqual(2 * $oneAmount['totalAmount'], $twoAmount['totalAmount']);
     // Housekeeping
     $this->db->delete('s_order_basket', array('sessionID = ?' => $this->session->get('sessionId')));
 }