示例#1
0
文件: Link.php 项目: aiesh/magento2
 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (!$this->_checkoutHelper->canOnepageCheckout() || !$this->_moduleManager->isOutputEnabled('Magento_Checkout')) {
         return '';
     }
     return parent::_toHtml();
 }
示例#2
0
 /**
  * @param string $error
  * @param float $summaryQty
  * @param array $totals
  * @param array $result
  *
  * @dataProvider dataProviderGetResponseData
  */
 public function testGetResponseData($error, $summaryQty, $totals, $result)
 {
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $quoteMock->expects($this->any())->method('getTotals')->willReturn($totals);
     $this->cartMock->expects($this->any())->method('getSummaryQty')->willReturn($summaryQty);
     $this->cartMock->expects($this->any())->method('getQuote')->willReturn($quoteMock);
     $this->checkoutHelperMock->expects($this->any())->method('formatPrice')->willReturnArgument(0);
     $this->assertEquals($result, $this->sidebar->getResponseData($error));
 }
示例#3
0
 /**
  * Retrieve create new account url
  *
  * @return string
  */
 public function getCreateAccountUrl()
 {
     $url = $this->getData('create_account_url');
     if ($url === null) {
         $url = $this->_customerUrl->getRegisterUrl();
     }
     if ($this->checkoutData->isContextCheckout()) {
         $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']);
     }
     return $url;
 }
 /**
  * Get checkout method
  *
  * @param Quote $quote
  * @return string
  */
 private function getCheckoutMethod(Quote $quote)
 {
     if ($this->customerSession->isLoggedIn()) {
         return Onepage::METHOD_CUSTOMER;
     }
     if (!$quote->getCheckoutMethod()) {
         if ($this->checkoutHelper->isAllowedGuestCheckout($quote)) {
             $quote->setCheckoutMethod(Onepage::METHOD_GUEST);
         } else {
             $quote->setCheckoutMethod(Onepage::METHOD_REGISTER);
         }
     }
     return $quote->getCheckoutMethod();
 }
示例#5
0
 /**
  * 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;
 }
示例#6
0
 public function testIsAllowedGuestCheckoutWithoutStore()
 {
     $quoteMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false);
     $store = null;
     $quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(1));
     $this->_scopeConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(true));
     $this->assertTrue($this->_helper->isAllowedGuestCheckout($quoteMock, $store));
 }
示例#7
0
 /**
  * @param bool $isLoggedIn
  * @param bool $isAllowedGuestCheckout
  * @dataProvider skipShortcutForGuestDataProvider
  */
 public function testSkipShortcutForGuest($isLoggedIn, $isAllowedGuestCheckout, $expected)
 {
     $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn($isLoggedIn);
     $quoteMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->willReturn($quoteMock);
     $this->checkoutDataMock->expects($this->any())->method('isAllowedGuestCheckout')->willReturn($isAllowedGuestCheckout);
     $this->assertEquals($expected, $this->block->skipShortcutForGuest());
 }
示例#8
0
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject $quoteMock
  */
 private function getCheckoutMethodStep(\PHPUnit_Framework_MockObject_MockObject $quoteMock)
 {
     $this->customerSessionMock->expects(self::once())->method('isLoggedIn')->willReturn(false);
     $quoteMock->expects(self::at(1))->method('getCheckoutMethod')->willReturn(null);
     $this->checkoutHelperMock->expects(self::once())->method('isAllowedGuestCheckout')->with($quoteMock)->willReturn(true);
     $quoteMock->expects(self::once())->method('setCheckoutMethod')->with(Onepage::METHOD_GUEST);
     $quoteMock->expects(self::at(2))->method('getCheckoutMethod')->willReturn(Onepage::METHOD_GUEST);
 }
示例#9
0
 /**
  * Don't display the shortcut button if customer is not logged in and guest mode is not allowed
  *
  * @return bool
  */
 public function skipShortcutForGuest()
 {
     if ($this->customerSession->isLoggedIn()) {
         return false;
     }
     if ($this->checkoutData->isAllowedGuestCheckout($this->checkoutSession->getQuote())) {
         return false;
     }
     return true;
 }
示例#10
0
 /**
  * Validate quote state to be integrated with one page checkout process
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function validate()
 {
     $quote = $this->getQuote();
     if ($quote->isMultipleShippingAddresses()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('There are more than one shipping addresses.'));
     }
     if ($quote->getCheckoutMethod() == self::METHOD_GUEST && !$this->_helper->isAllowedGuestCheckout($quote)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, guest checkout is not available.'));
     }
 }
示例#11
0
 /**
  * @dataProvider getCheckoutMethodDataProvider
  */
 public function testGetCheckoutMethod($isLoggedIn, $quoteCheckoutMethod, $isAllowedGuestCheckout, $expected)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue($isLoggedIn));
     /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quoteMock->expects($this->any())->method('setCheckoutMethod')->with($expected);
     $quoteMock->expects($this->any())->method('getCheckoutMethod')->will($this->returnValue($quoteCheckoutMethod));
     $this->checkoutHelperMock->expects($this->any())->method('isAllowedGuestCheckout')->will($this->returnValue($isAllowedGuestCheckout));
     $this->onepage->setQuote($quoteMock);
     $this->assertEquals($expected, $this->onepage->getCheckoutMethod());
 }
示例#12
0
 /**
  * Get checkout method
  *
  * @return string
  */
 public function getCheckoutMethod()
 {
     if ($this->_cart->getCustomerSession()->isLoggedIn()) {
         return \Magento\Checkout\Model\Type\Onepage::METHOD_CUSTOMER;
     }
     if (!$this->_cart->getQuote()->getCheckoutMethod()) {
         if ($this->_checkoutData->isAllowedGuestCheckout($this->_cart->getQuote())) {
             $this->_cart->getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_GUEST);
         } else {
             $this->_cart->getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER);
         }
     }
     return $this->_cart->getQuote()->getCheckoutMethod();
 }
示例#13
0
 /**
  * {@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())];
 }
示例#14
0
文件: Login.php 项目: aiesh/magento2
 /**
  * Check if guests checkout is allowed
  *
  * @return bool
  */
 public function isAllowedGuestCheckout()
 {
     return $this->_checkoutData->isAllowedGuestCheckout($this->getQuote());
 }
示例#15
0
 /**
  * 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);
 }
示例#16
0
 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;
 }
示例#17
0
 /**
  * Check if guest checkout is allowed
  *
  * @return bool
  */
 public function isGuestCheckoutAllowed()
 {
     return $this->checkoutHelper->isAllowedGuestCheckout($this->checkoutSession->getQuote());
 }
示例#18
0
 /**
  * Check if customer must be logged in to proceed with checkout
  *
  * @return bool
  * @codeCoverageIgnore
  */
 private function isCustomerLoginRequired()
 {
     return $this->checkoutHelper->isCustomerMustBeLogged();
 }
示例#19
0
 /**
  * @return bool
  */
 public function isPossibleOnepageCheckout()
 {
     return $this->_checkoutHelper->canOnepageCheckout();
 }
示例#20
0
 /**
  * Check if one page checkout is available
  *
  * @return bool
  */
 public function isPossibleOnepageCheckout()
 {
     return $this->_checkoutHelper->canOnepageCheckout() && !$this->getQuote()->getHasError();
 }
示例#21
0
 /**
  * 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;
 }
 /**
  * Display item price including tax
  *
  * @param Item|\Magento\Framework\DataObject $item
  * @return string
  */
 public function displayPriceInclTax(\Magento\Framework\DataObject $item)
 {
     return $this->displayPrices($this->_checkoutHelper->getBasePriceInclTax($item), $this->_checkoutHelper->getPriceInclTax($item));
 }