init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Sales\Block\Order\Item\Renderer;
|
||||
|
||||
use Magento\Catalog\Model\Product\OptionFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Stdlib\StringUtils;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Sales\Model\Order\Item;
|
||||
use Stemcell\Customer\Api\SalespersonRepositoryInterface;
|
||||
use Stemcell\Customer\Model\LabRepository;
|
||||
|
||||
class DefaultRenderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StringUtils $string,
|
||||
OptionFactory $productOptionFactory,
|
||||
private SalespersonRepositoryInterface $salespersonRepository,
|
||||
private LabRepository $labRepository,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $string, $productOptionFactory, $data);
|
||||
}
|
||||
|
||||
public function getSalespersonName(Item $orderItem)
|
||||
{
|
||||
if ($orderItem->getSalespersonId()) {
|
||||
$salesperson = $this->salespersonRepository->get($orderItem->getSalespersonId());
|
||||
return $salesperson->getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getLabBookingAccount(Item $orderItem)
|
||||
{
|
||||
if ($orderItem->getLabId()) {
|
||||
try {
|
||||
$lab = $this->labRepository->get($orderItem->getLabId());
|
||||
return $lab->getBookingAccount();
|
||||
} catch (LocalizedException $e) {
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Item $orderItem
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCustomDiscountPercent(Item $orderItem)
|
||||
{
|
||||
if ($orderItem->getData('customer_discount_percent')) {
|
||||
return number_format(
|
||||
$orderItem->getData('customer_discount_percent')*1.0,
|
||||
2, '.', ''
|
||||
).'%';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user