if ($ship_type['shipping_type'] == 90 or $ship_type['shipping_type'] == 92) { $ship_type = 'FDXG'; } else { $ship_type = 'FDXE'; } // simple array with transaction code, tracking number, carrier code $cancelData = array(0 => $transaction_code, 1 => ORDER_NUMBER . $order, 29 => $fedex_tracking, 3025 => $ship_type); $cancelData = $fedex_keys + $cancelData; // remove shipment data from the shipping manifest $delete_manifest_query = tep_db_query("delete from " . TABLE_SHIPPING_MANIFEST . " where orders_id = '" . $order . "'"); if ($delete_manifest_query) { } elseif (!$delete_manifest_query) { echo COULD_NOT_DELETE_ENTRIES; } // cancel the shipment $cancelRet = $fed->cancel_ground($cancelData); // todo: add appropriate error checking for at least some of the possible errors if ($error = $fed->getError()) { die(ERROR . $error); } // delete the tracking number from the order record $delete_trackNum = array('fedex_tracking' => ''); tep_db_perform(TABLE_ORDERS, $delete_trackNum, 'update', "orders_id = '" . $order . "'"); // ...mark the order record "pending"... $update_status = array('orders_status' => 2); tep_db_perform(TABLE_ORDERS, $update_status, 'update', "orders_id = '" . $order . "'"); // ...add a comment to the order history to show what we've done... $fedex_comments = ORDER_HISTORY_CANCELLED . $trackNum; tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . $order . "', 2, now(), '', '" . $fedex_comments . "')"); // ...delete the record from the manifest... tep_db_query("delete from " . TABLE_SHIPPING_MANIFEST . " where orders_id = '" . $order . "'");