Fix PUI error in editor

This commit is contained in:
Alex P. 2024-09-11 08:09:15 +03:00
parent f51dbfc6d3
commit c5381e34ad
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -9,6 +9,7 @@ declare( strict_types=1 );
namespace WooCommerce\PayPalCommerce\WcGateway\Helper; namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
use WC_Customer;
use WC_Order; use WC_Order;
use WC_Order_Item_Product; use WC_Order_Item_Product;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException; use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
@ -48,6 +49,7 @@ class PayUponInvoiceHelper {
* Checks whether checkout is ready for PUI. * Checks whether checkout is ready for PUI.
* *
* @return bool * @return bool
* @psalm-suppress RedundantConditionGivenDocblockType
*/ */
public function is_checkout_ready_for_pui(): bool { public function is_checkout_ready_for_pui(): bool {
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' ); $gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
@ -55,6 +57,10 @@ class PayUponInvoiceHelper {
return false; return false;
} }
if ( ! WC()->customer instanceof WC_Customer ) {
return false;
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing // phpcs:ignore WordPress.Security.NonceVerification.Missing
$billing_country = WC()->customer->get_billing_country(); $billing_country = WC()->customer->get_billing_country();
if ( empty( $billing_country ) || 'DE' !== $billing_country ) { if ( empty( $billing_country ) || 'DE' !== $billing_country ) {