mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +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;
|
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
||||||
|
|
||||||
|
use WC_Order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PayUponInvoiceHelper
|
* Class PayUponInvoiceHelper
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +48,7 @@ class PayUponInvoiceHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'EUR' !== get_woocommerce_currency() ) {
|
if ( ! $this->is_valid_currency() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,4 +58,24 @@ class PayUponInvoiceHelper {
|
||||||
|
|
||||||
return true;
|
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(
|
add_action(
|
||||||
'init',
|
'init',
|
||||||
function () use ( $c ) {
|
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();
|
( $c->get( 'wcgateway.pay-upon-invoice' ) )->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ class WCGatewayModule implements ModuleInterface {
|
||||||
$methods[] = $container->get( 'wcgateway.card-button-gateway' );
|
$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' );
|
$methods[] = $container->get( 'wcgateway.pay-upon-invoice-gateway' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue