Items.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Mustishipping checkout shipping
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Multishipping\Block\Checkout\Billing;
  12. /**
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Items extends \Magento\Sales\Block\Items\AbstractItems
  17. {
  18. /**
  19. * @var \Magento\Multishipping\Model\Checkout\Type\Multishipping
  20. */
  21. protected $_multishipping;
  22. /**
  23. * @var \Magento\Checkout\Model\Session
  24. */
  25. protected $_checkoutSession;
  26. /**
  27. * @param \Magento\Framework\View\Element\Template\Context $context
  28. * @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping
  29. * @param \Magento\Checkout\Model\Session $checkoutSession
  30. * @param array $data
  31. */
  32. public function __construct(
  33. \Magento\Framework\View\Element\Template\Context $context,
  34. \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping,
  35. \Magento\Checkout\Model\Session $checkoutSession,
  36. array $data = []
  37. ) {
  38. $this->_multishipping = $multishipping;
  39. $this->_checkoutSession = $checkoutSession;
  40. parent::__construct($context, $data);
  41. $this->_isScopePrivate = true;
  42. }
  43. /**
  44. * Get multishipping checkout model
  45. *
  46. * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping
  47. */
  48. public function getCheckout()
  49. {
  50. return $this->_multishipping;
  51. }
  52. /**
  53. * Retrieve quote model object
  54. *
  55. * @return \Magento\Quote\Model\Quote
  56. */
  57. public function getQuote()
  58. {
  59. return $this->_checkoutSession->getQuote();
  60. }
  61. /**
  62. * Retrieve virtual product edit url
  63. *
  64. * @return string
  65. */
  66. public function getVirtualProductEditUrl()
  67. {
  68. return $this->getUrl('checkout/cart');
  69. }
  70. /**
  71. * Retrieve virtual product collection array
  72. *
  73. * @return array
  74. */
  75. public function getVirtualQuoteItems()
  76. {
  77. $items = [];
  78. foreach ($this->getQuote()->getItemsCollection() as $_item) {
  79. if ($_item->getProduct()->getIsVirtual() && !$_item->getParentItemId()) {
  80. $items[] = $_item;
  81. }
  82. }
  83. return $items;
  84. }
  85. }