Skip to content

Commit

Permalink
v4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
algoritmika committed Oct 10, 2024
1 parent 9d6a3c2 commit 0a849ee
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
53 changes: 51 additions & 2 deletions includes/class-alg-wc-pgbc-convert.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Payment Gateway Currency for WooCommerce - Convert
*
* @version 3.9.3
* @version 4.0.1
* @since 2.0.0
*
* @author Algoritmika Ltd.
Expand Down Expand Up @@ -105,7 +105,7 @@ class Alg_WC_PGBC_Convert {
/**
* Constructor.
*
* @version 3.9.3
* @version 4.0.1
* @since 2.0.0
*
* @todo (dev) YITH WooCommerce Product Add-Ons: use `yith_wapo_addon_prices_on_cart` filter?
Expand Down Expand Up @@ -183,6 +183,7 @@ function __construct() {
// WooCommerce PayPal Payments
if ( 'yes' === get_option( 'alg_wc_pgbc_convert_currency_ppcp', 'no' ) ) {
add_action( 'init', array( $this, 'ppcp_init' ) );
add_filter( 'ppcp_request_args', array( $this, 'ppcp_request_args' ), PHP_INT_MAX );
}

// PayPal for WooCommerce by Angell EYE
Expand Down Expand Up @@ -392,6 +393,54 @@ function ppcp_localize( $l10n, $handle, $object_name ) {
return $l10n;
}

/**
* ppcp_request_args.
*
* @version 4.0.1
* @since 4.0.1
*/
function ppcp_request_args( $args ) {
if (
isset( $args['body'] ) &&
false !== ( $currency = $this->get_gateway_currency( 'ppcp-gateway' ) )
) {
$body = json_decode( $args['body'] );
if (
isset( $body->purchase_units ) &&
is_array( $body->purchase_units )
) {
foreach ( $body->purchase_units as &$purchase_unit ) {
// Amount
if ( isset( $purchase_unit->amount->currency_code ) ) {
$purchase_unit->amount->currency_code = $currency;
}
if ( isset( $purchase_unit->amount->breakdown->item_total->currency_code ) ) {
$purchase_unit->amount->breakdown->item_total->currency_code = $currency;
}
if ( isset( $purchase_unit->amount->breakdown->shipping->currency_code ) ) {
$purchase_unit->amount->breakdown->shipping->currency_code = $currency;
}
if ( isset( $purchase_unit->amount->breakdown->tax_total->currency_code ) ) {
$purchase_unit->amount->breakdown->tax_total->currency_code = $currency;
}
// Items
if (
isset( $purchase_unit->items ) &&
is_array( $purchase_unit->items )
) {
foreach ( $purchase_unit->items as &$item ) {
if ( isset( $item->unit_amount->currency_code ) ) {
$item->unit_amount->currency_code = $currency;
}
}
}
}
}
$args['body'] = json_encode( $body );
}
return $args;
}

/**
* woocommerce_paypal_express.
*
Expand Down
4 changes: 2 additions & 2 deletions payment-gateways-by-currency-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Payment Gateway Currency for WooCommerce
Plugin URI: https://wpfactory.com/item/payment-gateways-by-currency-for-woocommerce/
Description: Manage currencies for WooCommerce payment gateways. Beautifully.
Version: 4.0.0
Version: 4.0.1
Author: WPFactory
Author URI: https://wpfactory.com
Text Domain: payment-gateways-by-currency-for-woocommerce
Expand Down Expand Up @@ -31,7 +31,7 @@
}
}

defined( 'ALG_WC_PGBC_VERSION' ) || define( 'ALG_WC_PGBC_VERSION', '4.0.0' );
defined( 'ALG_WC_PGBC_VERSION' ) || define( 'ALG_WC_PGBC_VERSION', '4.0.1' );

defined( 'ALG_WC_PGBC_FILE' ) || define( 'ALG_WC_PGBC_FILE', __FILE__ );

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: wpcodefactory, algoritmika, anbinder, karzin, omardabbas, kousikmu
Tags: woocommerce, payment gateway, payment method, currency, multi-currency
Requires at least: 4.4
Tested up to: 6.6
Stable tag: 4.0.0
Stable tag: 4.0.1
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -77,6 +77,9 @@ With the [Pro version](https://wpfactory.com/item/payment-gateways-by-currency-f

== Changelog ==

= 4.0.1 - 10/10/2024 =
* Dev - WooCommerce PayPal Payments - Compatibility issue fixed.

= 4.0.0 - 07/10/2024 =
* Dev - "Key Manager" added.
* Dev - Code refactoring.
Expand Down

0 comments on commit 0a849ee

Please sign in to comment.