0

I have a carrier that get some info about orders from webservice and return a tracking number, I want to show this tracking number to customers in success page and also in order history

what function must use for this?

I used below functions but do not work

public function getTracking($trackings)
    {
        $authDetails = $this->_getAuthDetails();
        $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
        $order = Mage::getModel('sales/order')->load($orderId);
        $shippingId = $order->getShippingAddress()->getId();
        $address = Mage::getModel('sales/order_address')->load($shippingId);
        $firstname = $address->getFirstname();
        $lastname = $address->getLastname();
        $company = $address->getCompany();
        $jobTel = '0311';
        $homeTel = '0311';
        $mobile = '0913';
        $email = $address->getCustomerEmail();
        $street = $address->getStreetFull();
        $postcode = $address->getPostcode();
        $comment = 'for test';
        $regionId = $address->getRegion();
        $cityId = $address->getCity();
        $orders = '49^Windows Vista Home Edition^25000^100^1';
        $sendType = 0;
        $discount = 0;          

        $getTracking = $authDetails->RegisterOrder($firstname,$lastname,$company,$jobTel,$homeTel,$mobile,$email,$street,$postcode,$comment,$regionId,$cityId,$orders,$sendType,$discount);
        //die(print ($getTracking));

        return $getTracking;
    }

    public function getTrackingInfo($tracking)
    {
        $info = array();

        $result = $this->getTracking($tracking);

        if($result instanceof Mage_Shipping_Model_Tracking_Result){
            if ($trackings = $result->getAllTrackings()) {
                return $trackings[0];
            }
        }
        elseif (is_string($result) && !empty($result)) {
            return $result;
        }

        return false;
    }
4

If you have assigned this tracking number to the order then you should simply be able to loop through all the trackings attached to a order and call getNumber on each tracking object.

foreach ($order->getTracksCollection() as $_track){
    $_track->getNumber();
}

This is how the default magento code does it in the order history tab in the admin section: app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php

4

you can get tracking no anywhere by using below code ,if shipment is created..

        $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId); 
    OR
     $order = Mage::getModel('sales/order')->load($ordeId)
        $shipmentCollection = $order->getShipmentsCollection();


        foreach($shipmentCollection as $shipment){
        echo $shipmentIncrementId = $shipment->getIncrementId();
         $shipment=Mage::getModel('sales/order_shipment')->loadByIncrementId($shipmentIncrementId);
           foreach ($shipment->getAllTracks() as $track) {

               echo "<pre>";
               print_r($track->getData());
               echo "</pre>";
           }
          foreach ($shipment->getCommentsCollection() as $comment) {

               echo "<pre>";
               print_r($comment);
               echo "</pre>";
}
          }

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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