Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9322711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:09:41+00:00 2026-06-19T04:09:41+00:00

Some former programmers wrote this program using the Magento SOAP API V1 to mark

  • 0

Some former programmers wrote this program using the Magento SOAP API V1 to mark shipped orders as shipped. On the former Magento vs 1.5 platform it worked okay but now on vs 1.7 the tracking numbers themselves are not being imported. As you can see half way down I have my name commented out //Caitlin. The line above that is what the former programmers put, and the two lines after that are what I think the code is supposed to be for Magento vs 1.7, but I last time I tried this snippet I put a halt in their operations. Does this look correct to you? Any ideas?

   $comment = '<b><br>*** Order has shipped. ***</b><br/><br/>' . 
                           '<b>3PL order number:</b> ' .  $fields[1] . '<br/>' . 
                           '<b>Weight:</b> ' .  $fields[2] . '<br/>' . 
                           '<b>Shipped via:</b> ' .  $fields[3] . '<br/>' . 
                           '<b>Tracking number:</b> ' .  $fields[4] . '<br/>' . 
                           '<b>Ship date:</b> ' .  $fields[5] . '<br/>' . 
                           '<b>Postage:</b> ' .  $fields[6] . '<br/>' . 
                           '<b>Fulfillment:</b> ' .  $fields[7] . '<br/>' . 
                           '<b>Per packslip:</b> ' .  $fields[8];

            // Make shipment and add tracking number
            if ($fields[3] == 'UPS-RESIDENTIAL') { $shippedby = 'ups'; $shipname = 'UPS Ground'; }
            elseif ($fields[3] == 'UPS-2') { $shippedby = 'ups'; $shipname = 'UPS 2nd Day Air'; }
            elseif ($fields[3] == 'UPS-OVERNIGHT') { $shippedby = 'ups'; $shipname = 'UPS Next Day Air Saver'; }
            elseif ($fields[3] == 'USPS-PRI') { $shippedby = 'usps'; $shipname = 'USPS Priority'; }
            elseif ($fields[3] == 'CANADA') { $shippedby = 'custom'; $shipname = 'MSI Canada (Standard) '; }
            elseif ($fields[3] == 'MSITRACK') { $shippedby = 'custom'; $shipname = 'MSI Canada (Express)'; }
            else { $shippedby = 'custom'; }
            // Attempt to create the order, notify on failure
            try { 
            $newShipmentId = $client->call($sess_id, 'sales_order_shipment.create', array($ShippedOrderId, array(), $comment, true, false, $shippedby, $shipname, $fields[4]));

            //Caitlin
            //$newShipmentId = $client->call($sess_id, 'sales_order_shipment.create', array($ShippedOrderId, array(), $comment, true, false)); 
            //$newTrackId = $proxy->call($sessionId, 'sales_order_shipment.addTrack', array($newShipmentId, $shippedby, $shipname, $fields[4]));
            }
            catch (Exception $e) { echo 'Shipment creation failed on order '. $ShippedOrderId . ': ', $e->getMessage(); }


            // Add comment to order with all the info
             $client->call($sess_id, 'sales_order.addComment', array($ShippedOrderId, 'complete',  $comment,  false));
            $mail_content .= $line . "\n";
            $importcount++;
         }
      //}
   }

Edit 2/25/13


Using below implementation. I have error from running this script. I haven’t been able to test it though since I would have to when the cron runs at 5am.

// Make shipment and add tracking number
            if ($fields[3] == 'UPS-RESIDENTIAL') { $shippedby = 'ups'; $shipname = 'UPS Ground'; }
            elseif ($fields[3] == 'UPS-2') { $shippedby = 'ups'; $shipname = 'UPS 2nd Day Air'; }
            elseif ($fields[3] == 'UPS-OVERNIGHT') { $shippedby = 'ups'; $shipname = 'UPS Next Day Air Saver'; }
            elseif ($fields[3] == 'USPS-PRI') { $shippedby = 'usps'; $shipname = 'USPS Priority'; }
            elseif ($fields[3] == 'CANADA') { $shippedby = 'custom'; $shipname = 'MSI Canada (Standard) '; }
            elseif ($fields[3] == 'MSITRACK') { $shippedby = 'custom'; $shipname = 'MSI Canada (Express)'; }
            else { $shippedby = 'custom'; }


        /////////////////////////////////////////////       
        $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);

        $shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
        $shipment_collection->addAttributeToFilter('order_id', $orderId);
        $shipment_collection->load();

        $firstItem = $shipment_collection->getFirstItem();

        if(count($shipment_collection) > 1)
        {

            $track_no = $fields[4]; // insert tracking # string here

                $shipment = Mage::getModel('sales/order_shipment');
                $shipment->load($firstItem->getId());
                if($shipment->getId() != '')
                {
                    $track = Mage::getModel('sales/order_shipment_track')
                        ->setShipment($shipment)
                        ->setData('title', $shipname) // User syntax correct name here
                        ->setData('number', $track_no)
                        ->setData('carrier_code', $shippedby) // use code that matches DB code for ship method here
                        ->setData('order_id', $shipment->getData('order_id'));

                    $track->save();
                }

            return true;

        } else {

            $orderShip = $order->prepareShipment(); // can take sku => qty array
            $orderShip->register();
            $orderShip->sendEmail();

            $tracker = Mage::getModel( 'sales/order_shipment_track' );
            $tracker->setShipment( $orderShip );
            $tracker->setData( 'title', $shipname );
            $tracker->setData( 'number', $importData['Tracking Number'] );
            $tracker->setData( 'carrier_code', $shippedby );
            $tracker->setData( 'order_id', $orderId );

            $orderShip->addTrack($tracker);
            $orderShip->save();

            $order->setData('state', "complete");
            $order->setStatus("complete");
                $history = $order->addStatusHistoryComment('Order marked as complete by shipment code.', false);
                $history->setIsCustomerNotified(false);
            $order->save(); 
            /////////////////////////////////////////////////








            // Add comment to order with all the info
             $client->call($sess_id, 'sales_order.addComment', array($ShippedOrderId, 'complete',  $comment,  false));
            $mail_content .= $line . "\n";
            $importcount++;
         }
      //}
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T04:09:42+00:00Added an answer on June 19, 2026 at 4:09 am

    I would strip out the use of the API all together.

    Try this:

    $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
    
            $shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
            $shipment_collection->addAttributeToFilter('order_id', $orderId);
            $shipment_collection->load();
    
            $firstItem = $shipment_collection->getFirstItem();
    
            if(count($shipment_collection) > 1)
            {
    
                $track_no = "FEDEX9879879"; // insert tracking # string here
    
                    $shipment = Mage::getModel('sales/order_shipment');
                    $shipment->load($firstItem->getId());
                    if($shipment->getId() != '')
                    {
                        $track = Mage::getModel('sales/order_shipment_track')
                            ->setShipment($shipment)
                            ->setData('title', 'United Parcel Service') // User syntax correct name here
                            ->setData('number', $track_no)
                            ->setData('carrier_code', 'ups') // use code that matches DB code for ship method here
                            ->setData('order_id', $shipment->getData('order_id'));
    
                        $track->save();
                    }
    
                return true;
    
            } else {
    
                $orderShip = $order->prepareShipment(); // can take sku => qty array
                $orderShip->register();
                $orderShip->sendEmail();
    
                $tracker = Mage::getModel( 'sales/order_shipment_track' );
                $tracker->setShipment( $orderShip );
                $tracker->setData( 'title', 'United Parcel Service' );
                $tracker->setData( 'number', $importData['Tracking Number'] );
                $tracker->setData( 'carrier_code', 'ups' );
                $tracker->setData( 'order_id', $orderId );
    
                $orderShip->addTrack($tracker);
                $orderShip->save();
    
                $order->setData('state', "complete");
                $order->setStatus("complete");
                    $history = $order->addStatusHistoryComment('Order marked as complete by shipment code.', false);
                    $history->setIsCustomerNotified(false);
                $order->save();
    

    Notice the saving of orderShip automatically saves the tracker, and you CAN NOT save a tracker object on its own because it will fail foreign key constraint.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a former life I wrote some Visual Basic, and today I need to
At some point of my program I have an atom formed by what previously
Some background info: I'm trying to run a server program in python 2.5.1 (the
Some reasons i am experiencing this issue on my website. When the website loads
While digging through some old code put together by a former co-worker who's talents
I'm looking at some code written by a former employee where I work and
I'm in the midst of converting some tables that are using DisplayTag over to
I have some C programs without any explicit return from main, like this: int
I'm trying to grab out some information from Active Directory using Powershell, but I
For some reason my C program is refusing to convert elements of argv into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.