0

I have created two websites and install track order.

  1. website1
  2. website2

but I have placed an order in website1 and track order working now properly but one issue website2 order display track order.

now how to restrict the order in website2. please advance thanks for the help.

11

1 Answer 1

1

It is module bug. I have fixed module bug

Open file Mconnectsolutions\Trackorder\Controller\Index\Info.php and replace

code in function private function getOrder() at line number 59

from:

    private function getOrder()
    {
        if ($data = $this->getRequest()->getParams()) {
            $orderId = $data["order"];
            $email = $data["email"];
            $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
            $orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderId);
            $cEmail = $orderData->getCustomerEmail();


            if ($cEmail == $email) {
                $url = $this->link->getWindowUrl($orderData);
                $parts = parse_url($url);
                parse_str($parts['query'], $query);
                $hash = $query['hash'];

                if ($hash && $hash != '') {
                    $shippingInfoModel = $this->shippingInfoFactory->create()->loadByHash($hash);
                    $this->trackingData = $shippingInfoModel;
                }
                return $orderData;
            } else {
                return null;
            }
        }
    }

To:

    private function getOrder()
    {
        if ($data = $this->getRequest()->getParams()) {
            $orderId = $data["order"];
            $email = $data["email"];
            $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
            $orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderId);
            $cEmail = $orderData->getCustomerEmail();

            $storeManager = $objectManager->create('Magento\Store\Model\StoreManagerInterface');
            $currentStoreId = $storeManager->getStore()->getId();

            if ($cEmail == $email && $orderData->getStoreId() == $currentStoreId) {
                $url = $this->link->getWindowUrl($orderData);
                $parts = parse_url($url);
                parse_str($parts['query'], $query);
                $hash = $query['hash'];

                if ($hash && $hash != '') {
                    $shippingInfoModel = $this->shippingInfoFactory->create()->loadByHash($hash);
                    $this->trackingData = $shippingInfoModel;
                }
                return $orderData;
            } else {
                return null;
            }
        }
    }

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.