71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Lts\Catalog\Pricing\Render;
|
|
|
|
use Lts\Customer\Model\Netsuite\Status;
|
|
use Magento\Catalog\Model\Product;
|
|
use Magento\Customer\Model\Session;
|
|
use Magento\Framework\Json\Helper\Data;
|
|
use Magento\Framework\Math\Random;
|
|
use Magento\Framework\Pricing\Price\PriceInterface;
|
|
use Magento\Framework\Pricing\Render\RendererPool;
|
|
use Magento\Framework\View\Element\Template\Context;
|
|
|
|
class PriceBox extends \Magento\Catalog\Pricing\Render\PriceBox
|
|
{
|
|
protected Session $customerSession;
|
|
|
|
public function __construct(
|
|
Context $context,
|
|
Product $saleableItem,
|
|
PriceInterface $price,
|
|
RendererPool $rendererPool,
|
|
Data $jsonHelper,
|
|
Random $mathRandom,
|
|
Session $customerSession,
|
|
array $data = []
|
|
) {
|
|
parent::__construct(
|
|
$context,
|
|
$saleableItem,
|
|
$price,
|
|
$rendererPool,
|
|
$jsonHelper,
|
|
$mathRandom,
|
|
$data
|
|
);
|
|
$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();
|
|
var_dump($netsuiteStatus);
|
|
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();
|
|
}
|
|
} |