Link.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Block\Onepage;
  7. /**
  8. * One page checkout cart link
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @since 100.0.2
  13. */
  14. class Link extends \Magento\Framework\View\Element\Template
  15. {
  16. /**
  17. * @var \Magento\Checkout\Model\Session
  18. */
  19. protected $_checkoutSession;
  20. /**
  21. * @var \Magento\Checkout\Helper\Data
  22. */
  23. protected $_checkoutHelper;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Checkout\Model\Session $checkoutSession
  27. * @param \Magento\Checkout\Helper\Data $checkoutHelper
  28. * @param array $data
  29. */
  30. public function __construct(
  31. \Magento\Framework\View\Element\Template\Context $context,
  32. \Magento\Checkout\Model\Session $checkoutSession,
  33. \Magento\Checkout\Helper\Data $checkoutHelper,
  34. array $data = []
  35. ) {
  36. $this->_checkoutHelper = $checkoutHelper;
  37. $this->_checkoutSession = $checkoutSession;
  38. parent::__construct($context, $data);
  39. $this->_isScopePrivate = true;
  40. }
  41. /**
  42. * @return string
  43. */
  44. public function getCheckoutUrl()
  45. {
  46. return $this->getUrl('checkout');
  47. }
  48. /**
  49. * @return bool
  50. */
  51. public function isDisabled()
  52. {
  53. return !$this->_checkoutSession->getQuote()->validateMinimumAmount();
  54. }
  55. /**
  56. * @return bool
  57. */
  58. public function isPossibleOnepageCheckout()
  59. {
  60. return $this->_checkoutHelper->canOnepageCheckout();
  61. }
  62. }