From 21013adbca1e554a0adee5c0099b55b4ad2e3226 Mon Sep 17 00:00:00 2001 From: dinamiko Date: Mon, 28 Feb 2022 12:56:44 +0100 Subject: [PATCH 1/2] Do not display buttons in minicart if subscription in the cart and vaulting disabled --- .../js/modules/ContextBootstrap/MiniCartBootstap.js | 11 +++++++---- .../js/modules/Renderer/CreditCardRenderer.js | 2 +- modules/ppcp-button/src/Assets/SmartButton.php | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js b/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js index 090707ff3..1942417a0 100644 --- a/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js +++ b/modules/ppcp-button/resources/js/modules/ContextBootstrap/MiniCartBootstap.js @@ -22,9 +22,12 @@ class MiniCartBootstap { } shouldRender() { - return document.querySelector(this.gateway.button.mini_cart_wrapper) !== - null || document.querySelector(this.gateway.hosted_fields.mini_cart_wrapper) !== - null; + if (!this.gateway.can_save_vault_token) { + return; + } + + return document.querySelector(this.gateway.button.mini_cart_wrapper) !== null + || document.querySelector(this.gateway.hosted_fields.mini_cart_wrapper) !== null; } render() { @@ -40,4 +43,4 @@ class MiniCartBootstap { } } -export default MiniCartBootstap; \ No newline at end of file +export default MiniCartBootstap; diff --git a/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js b/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js index a4eb8f146..c22945073 100644 --- a/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js +++ b/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js @@ -181,7 +181,7 @@ class CreditCardRenderer { this.errorHandler.clear(); if (this.formValid && this.cardValid) { - const save_card = this.defaultConfig.save_card ? true : false; + const save_card = this.defaultConfig.can_save_vault_token ? true : false; let vault = document.getElementById('ppcp-credit-card-vault') ? document.getElementById('ppcp-credit-card-vault').checked : save_card; if (this.defaultConfig.enforce_vault) { diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index 6b15df926..cdb40ec6c 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -686,7 +686,7 @@ class SmartButton implements SmartButtonInterface { ), ), 'enforce_vault' => $this->has_subscriptions(), - 'save_card' => $this->can_save_vault_token(), + 'can_save_vault_token' => $this->can_save_vault_token(), 'bn_codes' => $this->bn_codes(), 'payer' => $this->payerData(), 'button' => array( From 5110209cfe7323a986a474e78240f1a7e9eaae05 Mon Sep 17 00:00:00 2001 From: dinamiko Date: Mon, 28 Feb 2022 14:14:14 +0100 Subject: [PATCH 2/2] Format code style --- modules/ppcp-button/src/Assets/SmartButton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-button/src/Assets/SmartButton.php b/modules/ppcp-button/src/Assets/SmartButton.php index cdb40ec6c..7c362d91e 100644 --- a/modules/ppcp-button/src/Assets/SmartButton.php +++ b/modules/ppcp-button/src/Assets/SmartButton.php @@ -686,7 +686,7 @@ class SmartButton implements SmartButtonInterface { ), ), 'enforce_vault' => $this->has_subscriptions(), - 'can_save_vault_token' => $this->can_save_vault_token(), + 'can_save_vault_token' => $this->can_save_vault_token(), 'bn_codes' => $this->bn_codes(), 'payer' => $this->payerData(), 'button' => array(