Fix psalm

This commit is contained in:
dinamiko 2022-05-09 10:36:38 +02:00
parent 49bc0f255c
commit f2284d49f5
2 changed files with 16 additions and 11 deletions

View file

@ -322,12 +322,12 @@ class PayUponInvoice {
'woocommerce_settings_checkout',
function () {
if (
$this->current_ppcp_settings_page_id === PayUponInvoiceGateway::ID
PayUponInvoiceGateway::ID === $this->current_ppcp_settings_page_id
&& ! $this->pui_product_status->pui_is_active()
) {
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
$gateway_enabled = $gateway_settings['enabled'] ?? '';
if($gateway_enabled === 'yes') {
if ( 'yes' === $gateway_enabled ) {
$gateway_settings['enabled'] = 'no';
update_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings', $gateway_settings );
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-pay-upon-invoice-gateway' );
@ -347,6 +347,10 @@ class PayUponInvoice {
* @return bool
*/
private function is_checkout_ready_for_pui(): bool {
if ( ! $this->pui_product_status->pui_is_active() ) {
return false;
}
$billing_country = filter_input( INPUT_POST, 'country', FILTER_SANITIZE_STRING ) ?? null;
if ( $billing_country && 'DE' !== $billing_country ) {
return false;

View file

@ -13,6 +13,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
/**
* Class DccProductStatus
@ -22,7 +23,7 @@ class PayUponInvoiceProductStatus {
/**
* Caches the status for the current load.
*
* @var string|null
* @var bool|null
*/
private $current_status_cache;
/**
@ -57,7 +58,7 @@ class PayUponInvoiceProductStatus {
* Whether the active/subscribed products support PUI.
*
* @return bool
* @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException Should a setting not be found.
* @throws NotFoundException Should a setting not be found.
*/
public function pui_is_active() : bool {
if ( is_bool( $this->current_status_cache ) ) {