private function sendXMLOrder($stack, $id_order) { //initializes Certissim if (_PS_VERSION_ >= '1.5' && Shop::isFeatureActive()) { $order = new Order($id_order); $sac = new CertissimSac($order->id_shop); } else { $sac = new CertissimSac(); } //sends the stream and catches the response $res = $sac->sendStacking($stack); $validstack = new CertissimValidstackResponse($res->getXML()); //if an error occured: log if ($res === false) { //connection to Certissim failed CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "Connexion échoué pour la commande " . (int) $order->id); return false; } if ($validstack->hasFatalError()) { //connexion to Certissim failed CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "L'envoi a échoué pour la commande " . (int) $order->id); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "Retour du script :"); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $res); //updates the databse entry self::updateCertissimOrder($id_order, array('avancement' => 'error', 'error' => $validstack->getError())); //swith the certisism order state to 'error' self::switchOrderToState($id_order, 'not concerned'); return false; } CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "---- Retour de Fia-Net pour la commande " . (int) $order->id . " ----"); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "{$res}"); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "-----------------------------------------------------------------"); //updates the order in the certissim table according to the certissim response foreach ($validstack->getResults() as $result) { CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "------"); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $result->returnAvancement()); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, $result); CertissimLogger::insertLog(__METHOD__ . ' : ' . __LINE__, "------"); switch ($result->returnAvancement()) { //if order under analysis: case 'encours': //set the avancement to 'encours' self::updateCertissimOrder($id_order, array('avancement' => $result->returnAvancement())); //sets the certissim order state to 'sent' self::switchOrderToState($id_order, 'sent'); break; //if an error occured during the analysis //if an error occured during the analysis case 'error': //updates the databse entry self::updateCertissimOrder($id_order, array('avancement' => $result->returnAvancement(), 'error' => $result->getDetail())); //swith the certisism order state to 'error' self::switchOrderToState($id_order, 'error'); break; default: CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, 'Avancement ' . $result->returnAvancement() . ' inconnu.'); break; } } return true; }