70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Lts\Catalog\Pricing\Render;
|
|
|
|
use Lts\Customer\Model\Netsuite\Status;
|
|
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
|
|
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
|
|
use Magento\Customer\Model\Session;
|
|
use Magento\Framework\Pricing\Price\PriceInterface;
|
|
use Magento\Framework\Pricing\Render\RendererPool;
|
|
use Magento\Framework\Pricing\SaleableInterface;
|
|
use Magento\Framework\View\Element\Template\Context;
|
|
|
|
class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox
|
|
{
|
|
protected Session $customerSession;
|
|
|
|
public function __construct(
|
|
Context $context,
|
|
SaleableInterface $saleableItem,
|
|
PriceInterface $price,
|
|
RendererPool $rendererPool,
|
|
Session $customerSession,
|
|
array $data = [],
|
|
SalableResolverInterface $salableResolver = null,
|
|
MinimalPriceCalculatorInterface $minimalPriceCalculator = null
|
|
) {
|
|
parent::__construct(
|
|
$context,
|
|
$saleableItem,
|
|
$price,
|
|
$rendererPool,
|
|
$data,
|
|
$salableResolver,
|
|
$minimalPriceCalculator
|
|
);
|
|
$this->customerSession = $customerSession;
|
|
}
|
|
|
|
protected function isShowPrice(): bool
|
|
{
|
|
$customerSession = $this->customerSession;
|
|
if ($customerSession->isLoggedIn()) {
|
|
$customer = $customerSession->getCustomer();
|
|
$dataCustomer = $customer->getDataModel();
|
|
$netsuiteStatus = $dataCustomer->getExtensionAttributes()?->getNetsuiteStatus();
|
|
|
|
$netsuiteStatus = $netsuiteStatus? strtolower($netsuiteStatus):$customer->getNetsuiteStatus();
|
|
if (!$netsuiteStatus) {
|
|
return false;
|
|
}
|
|
if ($netsuiteStatus!==null) {
|
|
$netsuiteStatus = strtolower($netsuiteStatus);
|
|
}
|
|
|
|
if (in_array($netsuiteStatus, Status::getApprovedStatuses())) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected function _toHtml()
|
|
{
|
|
if (!$this->isShowPrice()) {
|
|
return '';
|
|
}
|
|
return parent::_toHtml(); // TODO: Change the autogenerated stub
|
|
}
|
|
} |