diff --git a/Block/Catalog/Product/View/Applepay.php b/Block/Catalog/Product/View/Applepay.php index b56485b71..9870b9d79 100644 --- a/Block/Catalog/Product/View/Applepay.php +++ b/Block/Catalog/Product/View/Applepay.php @@ -60,41 +60,23 @@ public function __construct( /** * @return bool */ - public function canShowButton() + public function canShowButton($page) { - $result = false; - - if ($this->cart->getSummaryQty() - && - ($this->applepayConfigProvider->getActive() != 0) - && - ($this->applepayConfigProvider->getAvailableButtons()) - && - (in_array('Cart', $this->applepayConfigProvider->getAvailableButtons())) - ) { - $result = true; - } - - return $result; + return $this->cart->getSummaryQty() && + $this->isModuleActive() && + in_array($page, $this->applepayConfigProvider->getAvailableButtons()) && + $this->applepayConfigProvider->isApplePayEnabled($this->_storeManager->getStore()); } /** + * Check if Buckaroo module is active + * * @return bool */ - public function canShowProductButton() + public function isModuleActive() { - $result = false; - - if (($this->applepayConfigProvider->getActive() != 0) - && - ($this->applepayConfigProvider->getAvailableButtons()) - && - (in_array('Product', $this->applepayConfigProvider->getAvailableButtons())) - ) { - $result = true; - } - - return $result; + $status = $this->applepayConfigProvider->getActive(); + return $status == 1 || $status == 2; } /** @@ -102,10 +84,6 @@ public function canShowProductButton() */ public function getCheckoutConfig() { - if (!$this->canShowButton()) { - return null; - } - return json_encode($this->compositeConfigProvider->getConfig(), JSON_HEX_TAG); } diff --git a/Block/Catalog/Product/View/IdealFastCheckout.php b/Block/Catalog/Product/View/IdealFastCheckout.php index b2e87188b..5647009e3 100644 --- a/Block/Catalog/Product/View/IdealFastCheckout.php +++ b/Block/Catalog/Product/View/IdealFastCheckout.php @@ -69,31 +69,12 @@ public function __construct( * * @return bool */ - public function canShowProductButton() + public function canShowButton($page) { - if ($this->isModuleActive() && $this->isButtonEnabled()){ - return $this->idealConfig->canShowButtonForPage( - 'Product', - $this->_storeManager->getStore() - ); - } - return false; - } - - /** - * Determine if the cart button can be shown - * - * @return bool - */ - public function canShowCartButton() - { - if ($this->isModuleActive() && $this->isButtonEnabled()){ - return $this->idealConfig->canShowButtonForPage( - 'Cart', - $this->_storeManager->getStore() - ); - } - return false; + return ($this->isModuleActive() && + $this->idealConfig->isFastCheckoutEnabled($this->_storeManager->getStore()) && + $this->idealConfig->canShowButtonForPage($page, $this->_storeManager->getStore()) && + $this->idealConfig->isIDealEnabled($this->_storeManager->getStore())); } /** @@ -107,19 +88,6 @@ public function isModuleActive() return $status == 1 || $status == 2; } - /** - * Check if ideal fast checkout button is enabled - * - * @return mixed - */ - public function isButtonEnabled() - { - return $this->idealConfig->isFastCheckoutEnabled( - $this->_storeManager->getStore() - ); - } - - /** * Get logo based on chosen color setting * diff --git a/Block/Catalog/Product/View/PaypalExpress.php b/Block/Catalog/Product/View/PaypalExpress.php index afb4540bd..ea1dfc567 100644 --- a/Block/Catalog/Product/View/PaypalExpress.php +++ b/Block/Catalog/Product/View/PaypalExpress.php @@ -56,26 +56,11 @@ public function __construct( $this->encryptor = $encryptor; $this->paypalConfig = $paypalConfig; } - public function canShowProductButton() + public function canShowButton($page) { - if ($this->isModuleActive()){ - return $this->paypalConfig->canShowButtonForPage( - 'Product', - $this->_storeManager->getStore() - ); - } - return false; - } - - public function canShowCartButton() - { - if ($this->isModuleActive()){ - return $this->paypalConfig->canShowButtonForPage( - 'Cart', - $this->_storeManager->getStore() - ); - } - return false; + return $this->isModuleActive() && + $this->paypalConfig->canShowButtonForPage($page, $this->_storeManager->getStore()) && + $this->paypalConfig->isPayPalEnabled($this->_storeManager->getStore()); } /** @@ -88,6 +73,7 @@ public function isModuleActive() $status = $this->configProviderAccount->getActive(); return $status == 1 || $status == 2; } + /** * Get all data required * diff --git a/Model/ConfigProvider/Method/Applepay.php b/Model/ConfigProvider/Method/Applepay.php index 6cfe184ae..b5b686a5a 100644 --- a/Model/ConfigProvider/Method/Applepay.php +++ b/Model/ConfigProvider/Method/Applepay.php @@ -170,4 +170,8 @@ public function getBaseAllowedCurrencies() ]; } + public function isApplePayEnabled($store = null) + { + return $this->getConfigFromXpath(self::XPATH_APPLEPAY_ACTIVE, $store); + } } diff --git a/Model/ConfigProvider/Method/Ideal.php b/Model/ConfigProvider/Method/Ideal.php index e7dab3100..d32c8d64d 100644 --- a/Model/ConfigProvider/Method/Ideal.php +++ b/Model/ConfigProvider/Method/Ideal.php @@ -173,6 +173,11 @@ public function isFastCheckoutEnabled($store = null) return $this->getConfigFromXpath(self::XPATH_IDEAL_FAST_CHECKOUT_ENABLE, $store); } + public function isIDealEnabled($store = null) + { + return $this->getConfigFromXpath(self::XPATH_IDEAL_ACTIVE, $store); + } + public function getLogoColor($store = null) { return $this->getConfigFromXpath(self::XPATH_IDEAL_FAST_CHECKOUT_LOGO, $store); diff --git a/Model/ConfigProvider/Method/Paypal.php b/Model/ConfigProvider/Method/Paypal.php index 01b399c49..f063ae685 100644 --- a/Model/ConfigProvider/Method/Paypal.php +++ b/Model/ConfigProvider/Method/Paypal.php @@ -108,7 +108,7 @@ public function getExpressMerchantId($store = null) return $this->getConfigFromXpath(self::XPATH_PAYPAL_EXPRESS_MERCHANT_ID, $store); } /** - * Test if express button is enabled for the $page + * Test if express button is enabled for the $page * * @param string $page * @@ -124,4 +124,8 @@ public function canShowButtonForPage($page, $store = null) $pages = explode(",", $buttons); return in_array($page, $pages); } + public function isPayPalEnabled($store = null) + { + return $this->getConfigFromXpath(self::XPATH_PAYPAL_ACTIVE, $store); + } } diff --git a/view/frontend/templates/catalog/product/view/applepay.phtml b/view/frontend/templates/catalog/product/view/applepay.phtml index b8a329eef..8be785333 100644 --- a/view/frontend/templates/catalog/product/view/applepay.phtml +++ b/view/frontend/templates/catalog/product/view/applepay.phtml @@ -18,7 +18,7 @@ * @license https://tldrlegal.com/license/mit-license */ ?> -canShowProductButton()): ?> +canShowButton('Product')): ?>