1

In magento 2 order shipment email I have applied a change For "US" there the product price in shipment email should be (with out tax) & for rest of the store it would be with tax

I have used below code,

    $_item         = $block->getItem();
    $itemQty       = $_item->getQty();
    $_order        = $_item->getOrder();
    $store = $block->getOrder()->getStore()->getCode();
    $itemRowTotal = $store == 'us' ? $_item->getPrice() * $itemQty : $_item->getPriceInclTax() * $itemQty;

Issue is - I am not getting this in "$_item->getPriceInclTax() * $itemQty" other store

here is how i set shipment items in code & sent it in email template

   /**
     * @param Observer $observer
     * @param Template $templateContainer
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        try {
            $transportobj = $observer->getTransport();
            $transport    = $observer->getEvent()->getTransport();
            $shipment     = $transport['shipment'];
            $order        = $transport['order'];
            

            /* Already Shipped Items Start (Optimize) */
            $shipped   = array();
            $shipPart  = 0;
            $shipments = $order->getShipmentsCollection();
            foreach ($shipments as $shipmnt) {
                $shipPart++;
                if ($shipmnt->getId() == $shipment->getId()) {
                    continue;
                }
                foreach ($shipmnt->getAllItems() as $_item) {
                    if ($_item->getOrderItem()->getParentItem() || $_item->getQty() <= 0) {
                        continue;
                    }
                    $shipped[] = $_item;
                }
            }
            $shipped          = empty($shipped) ? false : $shipped;
            $isMultiShipOrder = !empty($pending) || $shipPart > 1;

            if ($isMultiShipOrder) {
                $shipment->setData('isMultiShipOrder', true);
                if ($shipPart == 1) {
                    $shipment->setData('isFirst', true);
                } else if (!$pending) {
                    $shipment->setData('isLast', true);
                } else if ($pending) {
                    $shipment->setData('hasMore', true);
                }
            }
            $shipment->setData('shipped', $shipped);
        } catch (\Exception $e) {
            $this->logger->critical($e);
        }
    }
1
  • any thoughts on this ?
    – devhs
    Jul 2, 2021 at 13:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.