diff --git a/_dev/js/front/src/core/app.js b/_dev/js/front/src/core/app.js index 30d323dc9..99d7e5f0a 100644 --- a/_dev/js/front/src/core/app.js +++ b/_dev/js/front/src/core/app.js @@ -12,6 +12,7 @@ import { PrestashopService } from '../service/prestashop.service'; import { PsCheckoutService } from '../service/ps-checkout.service'; import { TranslationService } from '../service/translation.service'; import { QuerySelectorService } from '../service/query-selector.service'; +import { PaymentOptionsLoaderComponent } from '../components/common/payment-options-loader.component'; function initService(app) { return (service) => () => new service(app); @@ -34,6 +35,7 @@ function initContainer(app) { bottle.factory('PsCheckoutApi', serviceFactory(PsCheckoutApi)); bottle.factory('PsCheckoutService', serviceFactory(PsCheckoutService)); bottle.factory('TranslationService', serviceFactory(TranslationService)); + bottle.factory('PaymentOptionsLoaderComponent', serviceFactory(PaymentOptionsLoaderComponent)); bottle.factory('$', (container) => { return (id) => container.TranslationService.getTranslationString(id); @@ -50,6 +52,7 @@ export class App { this.prestashopService = this.container.PrestashopService; this.psCheckoutService = this.container.PsCheckoutService; + this.paymentOptionsLoader = this.container.PaymentOptionsLoaderComponent; this.$ = this.container.$; @@ -111,6 +114,9 @@ export class App { if (this.prestashopService.isOrderPaymentStepPage()) { await this.renderCheckout(); return this; + } else if(this.prestashopService.isOrderPage()) { + this.paymentOptionsLoader.hide(); + return this; } } diff --git a/_dev/js/front/src/service/prestashop.service/index.js b/_dev/js/front/src/service/prestashop.service/index.js index 54bda1d26..cd112c189 100644 --- a/_dev/js/front/src/service/prestashop.service/index.js +++ b/_dev/js/front/src/service/prestashop.service/index.js @@ -48,6 +48,10 @@ export class PrestashopService { return !!this.instance.isOrderPaymentStepPage(); } + isOrderPage() { + return this.instance.isOrderPage(); + } + isIframeProductPage() { return !!this.instance.isIframeProductPage(); } diff --git a/_dev/js/front/src/service/prestashop.service/prestashop-ps1_6.service.js b/_dev/js/front/src/service/prestashop.service/prestashop-ps1_6.service.js index 3f50906bc..a593ada03 100644 --- a/_dev/js/front/src/service/prestashop.service/prestashop-ps1_6.service.js +++ b/_dev/js/front/src/service/prestashop.service/prestashop-ps1_6.service.js @@ -47,6 +47,10 @@ export class PrestashopPs1_6Service { return document.body.id === 'order-opc'; } + static isOrderPage() { + return document.body.id === 'order' || document.body.id === 'order-opc'; + } + static isOrderPersonalInformationStepPage() { return ( document.body.id === 'authentication' || diff --git a/_dev/js/front/src/service/prestashop.service/prestashop-ps1_7.service.js b/_dev/js/front/src/service/prestashop.service/prestashop-ps1_7.service.js index b9515d410..058cadfe1 100644 --- a/_dev/js/front/src/service/prestashop.service/prestashop-ps1_7.service.js +++ b/_dev/js/front/src/service/prestashop.service/prestashop-ps1_7.service.js @@ -32,6 +32,10 @@ export class PrestashopPs1_7Service { return document.querySelector('[data-module-name^="ps_checkout"]'); } + static isOrderPage() { + return document.body.id === 'checkout'; + } + static isOrderPersonalInformationStepPage() { if (document.body.id !== 'checkout') return false; const step = document.querySelector('#checkout-personal-information-step'); diff --git a/config.xml b/config.xml index 2e7d4c75a..11e96b682 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_checkout - + diff --git a/ps_checkout.php b/ps_checkout.php index 468b98856..3e703ab30 100755 --- a/ps_checkout.php +++ b/ps_checkout.php @@ -127,7 +127,7 @@ class Ps_checkout extends PaymentModule // Needed in order to retrieve the module version easier (in api call headers) than instanciate // the module each time to get the version - const VERSION = '2.15.1'; + const VERSION = '2.15.2'; const INTEGRATION_DATE = '2020-07-30'; @@ -153,7 +153,7 @@ public function __construct() // We cannot use the const VERSION because the const is not computed by addons marketplace // when the zip is uploaded - $this->version = '2.15.1'; + $this->version = '2.15.2'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->currencies = true; @@ -432,6 +432,15 @@ public function hookDisplayPersonalInformationTop() */ public function hookDisplayExpressCheckout() { + /** @var \PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository $psAccountRepository */ + $psAccountRepository = $this->getService('ps_checkout.repository.prestashop.account'); + /** @var \PrestaShop\Module\PrestashopCheckout\Repository\PaypalAccountRepository $paypalAccountRepository */ + $paypalAccountRepository = $this->getService('ps_checkout.repository.paypal.account'); + + if (!$psAccountRepository->onBoardingIsCompleted() || !$paypalAccountRepository->onBoardingIsCompleted()) { + return ''; + } + /** @var \PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayIn4XConfiguration $payIn4XService */ $payIn4XService = $this->getService('ps_checkout.pay_in_4x.configuration'); @@ -481,6 +490,15 @@ public function hookDisplayExpressCheckout() */ public function hookDisplayProductAdditionalInfo() { + /** @var \PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository $psAccountRepository */ + $psAccountRepository = $this->getService('ps_checkout.repository.prestashop.account'); + /** @var \PrestaShop\Module\PrestashopCheckout\Repository\PaypalAccountRepository $paypalAccountRepository */ + $paypalAccountRepository = $this->getService('ps_checkout.repository.paypal.account'); + + if (!$psAccountRepository->onBoardingIsCompleted() || !$paypalAccountRepository->onBoardingIsCompleted()) { + return ''; + } + /** @var \PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider $fundingSourceProvider */ $fundingSourceProvider = $this->getService('ps_checkout.funding_source.provider');