/** * @covers sBasket::sDeleteArticle */ public function testsDeleteArticle() { // No id, expect null $this->assertNull($this->module->sDeleteArticle(null)); // Random id, expect null $this->assertNull($this->module->sDeleteArticle(9999999)); $this->module->sSYSTEM->sSESSION_ID = uniqid(); $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID); // Get random article and add it to the basket $randomArticle = $this->db->fetchRow('SELECT detail.* FROM s_articles_details detail LEFT 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 avoid.articleID IS NULL AND article.id NOT IN ( SELECT articleID FROM s_articles_avoid_customergroups WHERE customergroupID = 1 ) AND (article.laststock = 0 OR detail.instock > 0) ORDER BY RAND() LIMIT 1'); $idOne = $this->module->sAddArticle($randomArticle['ordernumber'], 1); $this->assertEquals(1, $this->module->sCountBasket()); $this->module->sDeleteArticle($idOne); $this->assertEquals(0, $this->module->sCountBasket()); }
/** * 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])); } }