Colorado Timberline APIA Practical Guide to Successful Integration

OrderShipped Notification

Just implement the hook for the OrderShipped notification.

lib/subclasses/notification/OrderShippedCallback.php
<?php
class CtOrderShippedCallback extends CtApiCallback
{
   /**
    * the key here is you have a pre-hydrated CtOrderShipped
    * instance to work with; it should be easy to integrate..
    */

    protected static function _execute(CtOrderShipped $oDao)
    {
          // store relevant info in the db; imagine Propel data access layer
          // hydrate the order from the db, using the order no from notification
          $c = new Criteria();
          $c->add(OrderPeer::ID, $oDao->getCustomerPoNo());
          $oOrder = OrderPeer::doSelectOne($c);

          // now update some tracking info on the order
          // supposing you stored that in the order table ..
          $oOrder->setShipDate($oDao->getShipDate());
          $oOrder->setShipMethod($oDao->getShipVia());
          $oOrder->setTrackingNumber($oDao->getTrackingId());
          $oOrder->save();  // update record in db

          // now you might want to send a mail to the user
          // lookup user via order number .., compose mail
          mail($sUserEmail, 'Order Shipped!',
                  $sOrderShippedMsg, $sOrderShippedHeaders);
    }
}