Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. <?php
  2. /**
  3. * Copyright © 2016 Magento. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6.  
  7. // @codingStandardsIgnoreFile
  8.  
  9. ?>
  10.  
  11. <?php
  12. /** @var MagentoCatalogPricingRenderFinalPriceBox $block */
  13.  
  14. $productId = $block->getSaleableItem()->getId();
  15.  
  16. /** ex: MagentoCatalogPricingPriceRegularPrice */
  17. /** @var MagentoFrameworkPricingPricePriceInterface $priceModel */
  18. $priceModel = $block->getPriceType('regular_price');
  19.  
  20. /** ex: MagentoCatalogPricingPriceFinalPrice */
  21. /** @var MagentoFrameworkPricingPricePriceInterface $finalPriceModel */
  22. $finalPriceModel = $block->getPriceType('final_price');
  23. $idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
  24. $schema = ($block->getZone() == 'item_view') ? true : false;
  25.  
  26. ?>
  27. <?php if ($block->getSaleableItem()->getFinalPrice() == 0): ?>
  28. <span class="price-on-request">
  29. <?php echo __('Price on Request'); ?>
  30. <span>
  31. <?php else: ?>
  32. <?php if ($block->getPriceType('custom_price')->getCustomAmount() < $block->getPriceType('custom_price')->getCustomAmount(null,null,['regular_price'=>True,'price_type'=>'custom_price'])): ?>
  33. <span class="special-price">
  34. <?php /* @escapeNotVerified */ echo $block->renderAmount($block->getPriceType('custom_price')->getCustomAmount(), [
  35. 'display_label' => __('Special Price'),
  36. 'price_id' => $block->getPriceId('custom-special-price-' . $idSuffix),
  37. 'price_type' => 'custom_price',
  38. 'include_container' => true,
  39. 'schema' => $schema
  40. ]); ?>
  41. </span>
  42. <span class="old-price">
  43. <?php /* @escapeNotVerified */ echo $block->renderAmount($block->getPriceType('custom_price')->getCustomAmount(null,null,['regular_price'=>True,'price_type'=>'custom_price_regular']), [
  44. 'display_label' => __('Regular Price'),
  45. 'price_id' => $block->getPriceId('custom-price-' . $idSuffix),
  46. 'price_type' => 'custom_price',
  47. 'include_container' => true,
  48. 'skip_adjustments' => true
  49. ]); ?>
  50. </span>
  51. <?php elseif ($block->hasSpecialPrice()): ?>
  52. <span class="special-price">
  53. <?php /* @escapeNotVerified */ echo $block->renderAmount($finalPriceModel->getAmount(), [
  54. 'display_label' => __('Special Price'),
  55. 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
  56. 'price_type' => 'finalPrice',
  57. 'include_container' => true,
  58. 'schema' => $schema
  59. ]); ?>
  60. </span>
  61. <span class="old-price">
  62. <?php /* @escapeNotVerified */ echo $block->renderAmount($priceModel->getAmount(), [
  63. 'display_label' => __('Regular Price'),
  64. 'price_id' => $block->getPriceId('old-price-' . $idSuffix),
  65. 'price_type' => 'oldPrice',
  66. 'include_container' => true,
  67. 'skip_adjustments' => true
  68. ]); ?>
  69. </span>
  70. <?php else: ?>
  71. <?php /* @escapeNotVerified */ echo $block->renderAmount($block->getPriceType('final_price')->getCustomAmount(null,null,['price_type'=>'final_price']), [
  72. 'price_id' => $block->getPriceId('product-price-' . $idSuffix),
  73. 'price_type' => 'finalPrice',
  74. 'include_container' => true,
  75. 'schema' => $schema
  76. ]); ?>
  77. <?php endif; ?>
  78.  
  79. <?php if ($block->showMinimalPrice()): ?>
  80. <?php if ($block->getUseLinkForAsLowAs()):?>
  81. <a href="<?php /* @escapeNotVerified */ echo $block->getSaleableItem()->getProductUrl(); ?>" class="minimal-price-link">
  82. <?php /* @escapeNotVerified */ echo $block->renderAmountMinimal(); ?>
  83. </a>
  84. <?php else:?>
  85. <span class="minimal-price-link">
  86. <?php /* @escapeNotVerified */ echo $block->renderAmountMinimal(); ?>
  87. </span>
  88. <?php endif?>
  89. <?php endif; ?>
  90. <?php endif; ?>
  91.  
  92. /**
  93. * @param MagentoCheckoutBlockCartItemRenderer $subject
  94. * @param $result
  95. * @return string
  96. */
  97. public function afterGetUnitPriceHtml(
  98. MagentoCheckoutBlockCartItemRenderer $subject,
  99. $result
  100. ) {
  101. if ($subject->getProduct()->getFinalPrice() > 0) {
  102. return $result;
  103. }
  104. return __('Price on Request');
  105. }
  106.  
  107. /**
  108. * @param MagentoCheckoutBlockCartItemRenderer $subject
  109. * @param $result
  110. * @return string
  111. */
  112. public function afterGetRowTotalHtml(
  113. MagentoCheckoutBlockCartItemRenderer $subject,
  114. $result
  115. ) {
  116. if ($subject->getProduct()->getFinalPrice() > 0) {
  117. return $result;
  118. }
  119. return __('Price on Request');
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement