Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/512/sync order files on order callback trigger #476

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public function actionOrderCallback()
Craft::$app->end('Invalid orderId');
} else {
echo 'Order found'.PHP_EOL;
$order->logActivity('Order callback received.');
Craft::$app->getElements()->saveElement($order);
}

// don't process published orders
Expand Down Expand Up @@ -110,7 +112,15 @@ public function actionOrderCallback()
if (!$success) {
Craft::$app->end('Couldn’t save the order');
} else {
echo 'Saving order'.PHP_EOL;
echo 'Order changes saved'.PHP_EOL;
echo 'Starting file sync' . PHP_EOL;

foreach($order->getFiles() as $file) {
$translationService->updateFile($order, $file);
Translations::$plugin->fileRepository->saveFile($file);
}

echo 'File sync successful' . PHP_EOL;
}

Craft::$app->end('OK');
Expand Down Expand Up @@ -156,6 +166,8 @@ public function actionFileCallback()
Craft::$app->end('Couldn’t find the order');
} else {
echo 'Found order'.PHP_EOL;
$order->logActivity('File callback received.');
Craft::$app->getElements()->saveElement($order);
}

$translationService = $order->getTranslationService();
Expand Down