/** * If the user confirm the order, this function sends the buyer protection request * * @param Enlight_Hook_HookArgs $args * @return void */ public function onSaveOrder(Enlight_Hook_HookArgs $args) { set_time_limit(1000); $orderSubject = $args->getSubject(); $article = $this->isTsArticleInOrder($orderSubject); if(!empty($article)) { $config = $this->getTrustedShopBasicConfig(); $tsDataModel = new TrustedShopsDataModel(); $returnValue = $tsDataModel->sendBuyerProtectionRequest($orderSubject,$article["ordernumber"]); if(is_int($returnValue) && $returnValue > 0) { /* * Inserts the order to the trusted shops order table * The Status will be updated in the cronjob onRunTSCheckOrderState * Status Description: * Status 0 Pending * Status 1 Success * Status 3 Error */ $sql= "INSERT INTO `s_plugin_swag_trusted_shops_excellence_orders` (`ordernumber`, `ts_applicationId`, `status`) VALUES (?,?,0)"; Shopware()->Db()->query($sql, array($orderSubject->sOrderNumber, $returnValue)); $comment = $config["stateWaiting"]["description"]; $status = $config["stateWaiting"]["id"]; } else { //failed $comment = $config["stateError"]["description"]; $status = $config["stateError"]["id"]; } $sql = "UPDATE s_order SET internalcomment = ?, status = ? WHERE ordernumber = ?"; Shopware()->Db()->query($sql, array($comment, $status, $orderSubject->sOrderNumber)); } }