public function process() { $this->checkout->loadFromStore(); $this->handleCompleteCheckout(); $this->cart->clear(); return new ShopModeResponse(ShopModeResponse::VIEW_MODE_SUCCESS); }
public function process() { // update cart with post data $this->cartProcessor->handlePOST($this->cart); $this->cart->save(); return new ShopModeResponse(); }
/** * @param HeadAPI $api * @param CartWithShipping $cart * @param CartProcessor $cartProcessor * * @return string */ protected function getShopMode($api, $cart, $cartProcessor) { $defaultMode = $api->isTemplate() ? 'checkout' : 'cart'; if ($cart->totalUniqueItems() <= 0) { return $defaultMode; } $mode = $cartProcessor->getMode($defaultMode); return $mode; }
/** * @param CartWithShipping $cart * @param $cartTable */ protected function addCartSummary($cart, $cartTable) { $shippingCostsDisplay = new HtmlTagBuilder('tr', array('class' => 'shippingSum'), array(new HtmlTagBuilder('td', array('colspan' => '3', 'class' => 'number sumText'), array($this->i18n->translate('cartTable.shippingCosts'))), new HtmlTagBuilder('td', array('class' => 'number'), array($this->formatCurrency($cart->shipping()))), new HtmlTagBuilder('td', array('class' => 'action'), array('')))); $cartTable->append($shippingCostsDisplay); // SUM $sumTableElement = new HtmlTagBuilder('tr', array('class' => 'fullSum'), array(new HtmlTagBuilder('td', array('colspan' => '3', 'class' => 'number sumText'), array($this->i18n->translate('cartTable.fullPrice'))), new HtmlTagBuilder('td', array('class' => 'number'), array($this->formatCurrency($cart->totalWithShipping()))), new HtmlTagBuilder('td', array('class' => 'action'), array('')))); $cartTable->append($sumTableElement); // VAT $sumVatTableElement = new HtmlTagBuilder('tr', array('class' => 'vatSum'), array(new HtmlTagBuilder('td', array('colspan' => '4', 'class' => 'number sumText'), array(str_replace('%s', $this->formatCurrency($cart->taxWithShipping()), $this->i18n->translate('cartTable.includingVAT')))), new HtmlTagBuilder('td', array('class' => 'action'), array('')))); $cartTable->append($sumVatTableElement); }
/** * @param array $items * @param string $cartId * @param null|object $store * @param int $shippingCosts * @param int $shippingTax * * @return CartWithShipping */ protected function createCart($items = array(), $cartId = 'CART_ID', $store = null, $shippingCosts = 0, $shippingTax = 0) { if (!is_object($store)) { $store = $this->createMock('\\Cart\\Storage\\Store', null, null, null); } $cart = new CartWithShipping($cartId, $store, $shippingCosts, $shippingTax); if (count($items) > 0) { foreach ($items as $item) { if (is_array($item)) { $cart->add($this->createCartItem($item)); } else { $cart->add($item); } } } return $cart; }