Skip to content

Commit

Permalink
Use mbo installer only for shop context
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt75 committed Mar 11, 2024
1 parent 675c11c commit ef7f93d
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,6 @@ public function uninstallTabs()
public function getContent()
{
try {
$mboInstaller = new \Prestashop\ModuleLibMboInstaller\DependencyBuilder($this);
$requiredDependencies = $mboInstaller->handleDependencies();
$hasRequiredDependencies = $mboInstaller->areDependenciesMet();
/** @var \PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts $psAccountsFacade */
$psAccountsFacade = $this->getService('ps_accounts.facade');
/** @var \PrestaShop\PsAccountsInstaller\Installer\Presenter\InstallerPresenter $psAccountsPresenter */
Expand All @@ -387,8 +384,6 @@ public function getContent()
$contextPsAccounts = $psAccountsPresenter->present($this->name);
} catch (Exception $exception) {
$contextPsAccounts = [];
$requiredDependencies = [];
$hasRequiredDependencies = false;
$this->getLogger()->error(
'Failed to get PsAccounts context',
[
Expand Down Expand Up @@ -422,6 +417,27 @@ public function getContent()
}

$this->context->controller->addJS($boSdkUrl, false);
$isShopContext = !(Shop::isFeatureActive() && Shop::getContext() !== Shop::CONTEXT_SHOP);
$requiredDependencies = [];
$hasRequiredDependencies = true;

if ($isShopContext) {
try {
$mboInstaller = new \Prestashop\ModuleLibMboInstaller\DependencyBuilder($this);
$requiredDependencies = $mboInstaller->handleDependencies();
$hasRequiredDependencies = $mboInstaller->areDependenciesMet();
} catch (Exception $exception) {
$this->getLogger()->error(
'Failed to get required dependencies',
[
'exception' => get_class($exception),
'exceptionCode' => $exception->getCode(),
'exceptionMessage' => $exception->getMessage(),
]
);
}
}

$this->context->smarty->assign([
'requiredDependencies' => $requiredDependencies,
'hasRequiredDependencies' => $hasRequiredDependencies,
Expand Down

0 comments on commit ef7f93d

Please sign in to comment.