TierPriceBox.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ConfigurableProduct\Pricing\Render;
  7. use Magento\Catalog\Pricing\Price\TierPrice;
  8. /**
  9. * Responsible for displaying tier price box on configurable product page.
  10. *
  11. * @package Magento\ConfigurableProduct\Pricing\Render
  12. */
  13. class TierPriceBox extends FinalPriceBox
  14. {
  15. /**
  16. * @inheritdoc
  17. */
  18. public function toHtml()
  19. {
  20. // Hide tier price block in case of MSRP or in case when no options with tier price.
  21. if (!$this->isMsrpPriceApplicable() && $this->isTierPriceApplicable()) {
  22. return parent::toHtml();
  23. }
  24. }
  25. /**
  26. * Check if at least one of simple products has tier price.
  27. *
  28. * @return bool
  29. */
  30. private function isTierPriceApplicable()
  31. {
  32. $product = $this->getSaleableItem();
  33. foreach ($product->getTypeInstance()->getUsedProducts($product) as $simpleProduct) {
  34. if ($simpleProduct->isSalable() &&
  35. !empty($simpleProduct->getPriceInfo()->getPrice(TierPrice::PRICE_CODE)->getTierPriceList())
  36. ) {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. }