/** * Add tax data to result * * @param \Magento\Checkout\CustomerData\Cart $subject * @param array $result * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result) { $result['subtotal_incl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalInclTax()); $result['subtotal_excl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalExclTax()); $items = $this->getQuote()->getAllVisibleItems(); if (is_array($result['items'])) { foreach ($result['items'] as $key => $itemAsArray) { if ($item = $this->findItemById($itemAsArray['item_id'], $items)) { $this->itemPriceRenderer->setItem($item); $this->itemPriceRenderer->setTemplate('checkout/cart/item/price/sidebar.phtml'); $result['items'][$key]['product_price'] = $this->itemPriceRenderer->toHtml(); } } } return $result; }
public function testFormatPrice() { $price = 5.5; $quoteMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false); $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['formatPrice', '__wakeup'], [], '', false); $this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $this->priceCurrency->expects($this->once())->method('format')->will($this->returnValue('5.5')); $this->assertEquals('5.5', $this->_helper->formatPrice($price)); }
/** * {@inheritdoc} */ protected function doGetItemData() { $imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail'); return ['options' => $this->getOptionList(), 'qty' => $this->item->getQty() * 1, 'item_id' => $this->item->getId(), 'configure_url' => $this->getConfigureUrl(), 'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(), 'product_name' => $this->item->getProduct()->getName(), 'product_url' => $this->getProductUrl(), 'product_has_url' => $this->hasProductUrl(), 'product_price' => $this->checkoutHelper->formatPrice($this->item->getCalculationPrice()), 'product_image' => ['src' => $imageHelper->getUrl(), 'alt' => $imageHelper->getLabel(), 'width' => $imageHelper->getWidth(), 'height' => $imageHelper->getHeight()], 'canApplyMsrp' => $this->msrpHelper->isShowBeforeOrderConfirm($this->item->getProduct()) && $this->msrpHelper->isMinimalPriceLessMsrp($this->item->getProduct())]; }
/** * Retrieve subtotal block html * * @return string */ protected function getSubtotalHtml() { $totals = $this->cart->getQuote()->getTotals(); $subtotal = isset($totals['subtotal']) && $totals['subtotal'] instanceof Total ? $totals['subtotal']->getValue() : 0; return $this->helperData->formatPrice($subtotal); }
/** * {@inheritdoc} */ public function getSectionData() { $totals = $this->getQuote()->getTotals(); return ['summary_count' => $this->getSummaryCount(), 'subtotal' => isset($totals['subtotal']) ? $this->checkoutHelper->formatPrice($totals['subtotal']->getValue()) : 0, 'possible_onepage_checkout' => $this->isPossibleOnepageCheckout(), 'items' => $this->getRecentItems(), 'extra_actions' => $this->layout->createBlock('Magento\\Catalog\\Block\\ShortcutButtons')->toHtml(), 'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed()]; }
/** * Add tax data to result * * @param \Magento\Checkout\CustomerData\Cart $subject * @param array $result * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result) { $result['subtotal_incl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalInclTax()); $result['subtotal_excl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalExclTax()); return $result; }
public function getCarriergroupShippingHtml($encodedDetails) { $decodedDetails = self::decode($encodedDetails); $htmlText = ''; foreach ($decodedDetails as $shipLine) { if (!is_array($shipLine) || !array_key_exists('name', $shipLine)) { continue; } $htmlText .= $shipLine['name'] . ' : ' . $shipLine['carrierTitle'] . ' - ' . $shipLine['methodTitle'] . ' '; $htmlText .= " " . $this->checkoutHelper->formatPrice($shipLine['price']) . '<br/>'; } return $htmlText; }