Skip to content

Commit

Permalink
Added front office SDK version to env
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ committed Jul 12, 2024
1 parent b3f14a7 commit aecc24d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1102,20 +1102,31 @@ public function hookActionFrontControllerSetMedia()
/** @var \PrestaShop\Module\PrestashopCheckout\Environment\Env $env */
$env = $this->getService(\PrestaShop\Module\PrestashopCheckout\Environment\Env::class);

$foSDkUrl = $env->getEnv('CHECKOUT_FO_SDK_URL');
$foSdkUrl = $env->getEnv('CHECKOUT_FO_SDK_URL');
if (substr($foSdkUrl, -3) !== '.js') {
$foSdkVersion = $env->getEnv('CHECKOUT_FO_SDK_VERSION');
if (empty($foSdkVersion)) {
/** @var \PrestaShop\Module\PrestashopCheckout\Version\Version $version */
$version = $this->getService('ps_checkout.module.version');
$majorModuleVersion = explode('.', $version->getSemVersion())[0];
$foSdkVersion = "$majorModuleVersion.X.X";
}

$foSdkUrl = $foSdkUrl . $foSdkVersion . '/sdk/ps_checkout-fo-sdk.js';
}

if (method_exists($this->context->controller, 'registerJavascript')) {
$this->context->controller->registerJavascript(
$this->name . 'Front',
$foSDkUrl,
$foSdkUrl,
[
'position' => 'bottom',
'priority' => 201,
'server' => 'remote',
]
);
} else {
$this->context->controller->addJS($foSDkUrl, false);
$this->context->controller->addJS($foSdkUrl, false);
}
}

Expand Down

0 comments on commit aecc24d

Please sign in to comment.