Is their any way to Get product price including tax in order confirmation email ?
-
any thoughts on this ?– NewDeveloperAug 2, 2021 at 10:48
-
Can you explain your requirement?– Dhiren VasoyaAug 3, 2021 at 4:27
-
In a customized order confirmation email template, there is customization that displays ordered products, but the price for that products is not tax included– NewDeveloperAug 3, 2021 at 5:05
1 Answer
This might help
Create helper class
use Magento\Sales\Api\OrderItemRepositoryInterface;
class Data extends AbstractHelper
{
/**
* Order Item Repository
*
* @var OrderItemRepositoryInterface
*/
private $orderItemRepository;
public function __construct(
OrderItemRepositoryInterface $orderItemRepository
) {
$this->orderItemRepository = $orderItemRepository;
}
/**
* Get price including tax
*/
public function getPriceInclTaxByItemId($itemId)
{
return $this->orderItemRepository->get($itemId);
}
In phtml file
/** @var $_item \Magento\Sales\Model\Order\Item */
$_item = $block->getItem();
$ordered_item_id = $_item->getOrderItemId() ? $_item->getOrderItemId() : $_item->getId();
$itemPrice = $helper->getPriceInclTaxByItemId($ordered_item_id);