public function infoAction() { $view = $this->View(); $view->sBasketQuantity = isset($this->session->sBasketQuantity) ? $this->session->sBasketQuantity : 0; $view->sBasketAmount = isset($this->session->sBasketAmount) ? $this->session->sBasketAmount : 0; $view->sNotesQuantity = isset($this->session->sNotesQuantity) ? $this->session->sNotesQuantity : $this->module->sCountNotes(); $view->sUserLoggedIn = !empty(Shopware()->Session()->sUserId); }
/** * @covers sAdmin::sGetPremiumShippingcosts */ public function testsGetPremiumShippingcosts() { // No basket, return false, $this->assertFalse($this->module->sGetPremiumShippingcosts()); $countries = $this->module->sGetCountryList(); foreach ($countries as $country) { if ($country['countryiso']) { $germany = $country; break; } } $this->module->sSYSTEM->sSESSION_ID = uniqid(); $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID); $this->basketModule->sAddArticle('SW10010'); // With country data, no dispatch method $this->assertEquals(array('brutto' => 0, 'netto' => 0), $this->module->sGetPremiumShippingcosts($germany)); // With dispatch method $this->session->offsetSet('sDispatch', 9); $result = $this->module->sGetPremiumShippingcosts($germany); $this->assertArrayHasKey('brutto', $result); $this->assertArrayHasKey('netto', $result); $this->assertArrayHasKey('value', $result); $this->assertArrayHasKey('factor', $result); $this->assertArrayHasKey('surcharge', $result); $this->assertArrayHasKey('tax', $result); }
/** * 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); }
/** * 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])); } }
/** * @covers sBasket::sAddArticle */ public function testsAddArticle() { // No id, expect false $this->assertFalse($this->module->sAddArticle(null)); $this->module->sSYSTEM->sSESSION_ID = uniqid(); $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID); // Get random article with stock controll and add it to the basket $randomArticleOne = $this->db->fetchRow('SELECT detail.* FROM s_articles_details detail INNER JOIN s_articles article ON article.id = detail.articleID LEFT JOIN s_articles_avoid_customergroups avoid ON avoid.articleID = article.id WHERE detail.active = 1 AND laststock = 1 AND instock > 3 AND avoid.articleID IS NULL AND article.id NOT IN ( SELECT articleID FROM s_articles_avoid_customergroups WHERE customergroupID = 1 ) ORDER BY RAND() LIMIT 1'); // Adding article without quantity adds one $this->module->sAddArticle($randomArticleOne['ordernumber']); $basket = $this->module->sGetBasket(); $this->assertEquals(1, $basket['Quantity']); $this->assertEquals(1, $basket['content'][0]['quantity']); // Adding article with quantity adds correctly, finds stacks $this->module->sAddArticle($randomArticleOne['ordernumber'], 2); $basket = $this->module->sGetBasket(); $this->assertEquals(1, $basket['Quantity']); $this->assertEquals(3, $basket['content'][0]['quantity']); // Start over $this->module->sDeleteBasket(); // Adding article with quantity over stock, check that we have the available stock $this->module->sAddArticle($randomArticleOne['ordernumber'], $randomArticleOne['instock'] + 200); $basket = $this->module->sGetBasket(); $this->assertEquals(1, $basket['Quantity']); $this->assertEquals(min($randomArticleOne['instock'], 100), $basket['content'][0]['quantity']); // Start over $this->module->sDeleteBasket(); // Get random article and add it to the basket $randomArticleTwo = $this->db->fetchRow('SELECT detail.* FROM s_articles_details detail INNER JOIN s_articles article ON article.id = detail.articleID WHERE detail.active = 1 AND laststock = 0 AND instock > 20 AND instock < 70 AND article.id NOT IN ( SELECT articleID FROM s_articles_avoid_customergroups WHERE customergroupID = 1 ) ORDER BY RAND() LIMIT 1'); // Adding article with quantity over stock, check that we have the desired quantity $this->module->sAddArticle($randomArticleTwo['ordernumber'], $randomArticleTwo['instock'] + 20); $basket = $this->module->sGetBasket(); $this->assertEquals(1, $basket['Quantity']); $this->assertEquals(min($randomArticleTwo['instock'] + 20, 100), $basket['content'][0]['quantity']); // Housekeeping $this->db->delete('s_order_basket', array('sessionID = ?' => $this->session->get('sessionId'))); }