<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use MagentoFrameworkPricingAmountAmountFactory;
?>
<?php
/** @var MagentoCatalogPricingRenderFinalPriceBox $block */
/** ex: MagentoCatalogPricingPriceRegularPrice */
/** @var MagentoFrameworkPricingPricePriceInterface $priceModel */
$priceModel = $block->getPriceType('regular_price');
/** ex: MagentoCatalogPricingPriceFinalPrice */
/** @var MagentoFrameworkPricingPricePriceInterface $finalPriceModel */
$finalPriceModel = $block->getPriceType('final_price');
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
$schema = ($block->getZone() == 'item_view') ? true : false;
?>
<?php
$customer= $block->getLayout()->createBlock('JJLoggedOutBlockCustomerGroupId');
$group = $customer->getCustomerGroupId();
?>
<?php
/** @var MagentoCatalogPricingRenderFinalPriceBox $block */
// /** Get Regular Price */
// $priceModel = $block->getPriceType('regular_price');
// echo "<p><strong>Regular Price:</strong> " . ($priceModel ? $priceModel->getAmount()->getValue() : 0) . "</p>";
/** Get Final Price */
$finalPriceModel = $block->getPriceType('final_price');
$finalPrice = $finalPriceModel ? $finalPriceModel->getAmount()->getValue() : 0;
// /** Get Special Price */
// $specialPriceModel = $block->getPriceType('special_price');
// $specialPrice = $specialPriceModel ? $specialPriceModel->getAmount()->getValue() : 0;
// if ($specialPrice > 0) {
// echo "<p><strong>Special Price:</strong> " . $specialPrice . "</p>";
// }
/** Get Customer Group ID */
$customer = $block->getLayout()->createBlock('JJLoggedOutBlockCustomerGroupId');
$groupId = $customer->getCustomerGroupId();
/** Get Tier Prices */
$product = $block->getSaleableItem();
$product->getPriceInfo()->getPrice('final_price')->getAmount();
$tierPrices = $product->getTierPrice();
$tierPriceValue = null;
/** Find the tier price for the current customer group */
foreach ($tierPrices as $tierPrice) {
if ($tierPrice['cust_group'] == $groupId ) { // 32000 is for all groups
$tierPriceValue = $tierPrice['price'];
break;
}
}
/** Display Tier Price */
// if ($tierPriceValue !== null) { echo "<p><strong>Tier Price:</strong> " . $tierPriceValue . "</p>";}
?>
<!--Adding the Base Price level id as 4 -->
<div class="pricebox-base-wrapper <?= ($group != 4) ? 'pricebox-level-wrapper' : '' ?>">
<?php if ($block->hasSpecialPrice()) :?>
<?php
$displayLabel = ($group != 4) ? 'Price: ' : __('Special Price'); // Modified label text
$specialPriceClass = ($group != 4) ? 'special-price-alt' : 'special-price';
$specialPriceClass .= ($group != 4) ? 'custom-special-discount' : '';
$amountFactory = MagentoFrameworkAppObjectManager::getInstance()->get(AmountFactory::class);
//$tierPriceAmount = $tierPriceValue ? $amountFactory->create($tierPriceValue) : $finalPriceModel->getAmount();
$tierPriceAmount = ($tierPriceValue && $group != 4) ? $amountFactory->create($tierPriceValue) : $finalPriceModel->getAmount();
?>
<span class="<?= $specialPriceClass ?>">
<?= /* @noEscape */ $block->renderAmount($tierPriceAmount, [
'display_label' => $displayLabel ,
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema
]); ?>
</span>
<?php if ($group == 4) : ?>
<span class="old-price">
<?= /* @noEscape */ $block->renderAmount($priceModel->getAmount(), [
'display_label' => __('Price: '),
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
'price_type' => 'oldPrice',
'include_container' => true,
'skip_adjustments' => true
]); ?>
</span>
<?php endif; ?>
<?php else :?>
<?php if ($group == 4) : ?>
<span class="special-price">
<?php if ($block->getUseLinkForAsLowAs()) :?>
<a href="<?= $block->escapeUrl($block->getSaleableItem()->getProductUrl()) ?>" class="minimal-price-link">
<?= /* @noEscape */ $block->renderAmountMinimal() ?>
</a>
<?php else :?>
<span class="minimal-price-link">
<?= /* @noEscape */ $block->renderAmountMinimal() ?>
</span>
<?php endif?>
</span>
<?php endif; ?>
<?= /* @noEscape */ $block->renderAmount($finalPriceModel->getAmount(), [
'display_label' => __('Price: '),
'price_id' => $block->getPriceId('product-price-' . $idSuffix),
'price_type' => 'finalPrice',
'include_container' => true,
'schema' => $schema
]); ?>
<?php endif; ?>
</div>