mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge branch 'trunk' into refactor-saved-credit-card
This commit is contained in:
commit
0f47b2ef37
2 changed files with 25 additions and 3 deletions
|
@ -9,6 +9,8 @@ declare( strict_types=1 );
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
||||
|
||||
use WC_Order;
|
||||
|
||||
/**
|
||||
* Class PayUponInvoiceHelper
|
||||
*/
|
||||
|
@ -46,7 +48,7 @@ class PayUponInvoiceHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( 'EUR' !== get_woocommerce_currency() ) {
|
||||
if ( ! $this->is_valid_currency() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -56,4 +58,24 @@ class PayUponInvoiceHelper {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if currency is allowed for PUI.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_valid_currency(): bool {
|
||||
global $wp;
|
||||
$order_id = isset( $wp->query_vars['order-pay'] ) ? (int) $wp->query_vars['order-pay'] : 0;
|
||||
if ( 0 === $order_id ) {
|
||||
return 'EUR' === get_woocommerce_currency();
|
||||
}
|
||||
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( is_a( $order, WC_Order::class ) ) {
|
||||
return 'EUR' === $order->get_currency();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
add_action(
|
||||
'init',
|
||||
function () use ( $c ) {
|
||||
if ( 'DE' === $c->get( 'api.shop.country' ) && 'EUR' === $c->get( 'api.shop.currency' ) ) {
|
||||
if ( 'DE' === $c->get( 'api.shop.country' ) ) {
|
||||
( $c->get( 'wcgateway.pay-upon-invoice' ) )->init();
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
$methods[] = $container->get( 'wcgateway.card-button-gateway' );
|
||||
}
|
||||
|
||||
if ( 'DE' === $container->get( 'api.shop.country' ) && 'EUR' === $container->get( 'api.shop.currency' ) ) {
|
||||
if ( 'DE' === $container->get( 'api.shop.country' ) ) {
|
||||
$methods[] = $container->get( 'wcgateway.pay-upon-invoice-gateway' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue