mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix psalm
This commit is contained in:
parent
49bc0f255c
commit
f2284d49f5
2 changed files with 16 additions and 11 deletions
|
@ -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§ion=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;
|
||||
|
|
|
@ -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 ) ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue