From 977c2b65e7e421a226b422a8497557cd76ece243 Mon Sep 17 00:00:00 2001 From: Pond Date: Tue, 27 Aug 2024 18:14:16 +0700 Subject: [PATCH 1/4] Fix skipt order lines calculate items price with quantity --- includes/Gateways/ReepayGateway.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/Gateways/ReepayGateway.php b/includes/Gateways/ReepayGateway.php index 8226f155..c8ed76d2 100644 --- a/includes/Gateways/ReepayGateway.php +++ b/includes/Gateways/ReepayGateway.php @@ -1400,7 +1400,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) { * * @return array */ - public function get_order_items( WC_Order $order, bool $only_not_settled = false ): array { + public function get_order_items( WC_Order $order, bool $only_not_settled = false, $skipt_order_line = false ): array { $prices_incl_tax = wc_prices_include_tax(); $items = array(); @@ -1429,7 +1429,11 @@ public function get_order_items( WC_Order $order, bool $only_not_settled = false $price = OrderCapture::get_item_price( $order_item, $order ); $tax_percent = $price['tax_percent']; - $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ) / $order_item->get_quantity(), 2 ); + if($skipt_order_line){ + $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ), 2 ); + }else{ + $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ) / $order_item->get_quantity(), 2 ); + } if ( $only_not_settled && ! empty( $order_item->get_meta( 'settled' ) ) ) { continue; @@ -1568,7 +1572,7 @@ public function get_order_items( WC_Order $order, bool $only_not_settled = false public function get_skip_order_lines_amount( WC_Order $order ) { $total_amount = 0; - $items = $this->get_order_items( $order ); + $items = $this->get_order_items( $order, false, true ); if ( $items ) { foreach ( $items as $item ) { From d2170b67f828fc0a652b3769480d6df6d500c440 Mon Sep 17 00:00:00 2001 From: Pond Date: Tue, 27 Aug 2024 18:24:46 +0700 Subject: [PATCH 2/4] Fix code standard --- includes/Gateways/ReepayGateway.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/Gateways/ReepayGateway.php b/includes/Gateways/ReepayGateway.php index c8ed76d2..421a883e 100644 --- a/includes/Gateways/ReepayGateway.php +++ b/includes/Gateways/ReepayGateway.php @@ -1397,6 +1397,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) { * * @param WC_Order $order order to get items. * @param bool $only_not_settled get only not settled items. + * @param bool $skipt_order_line get item price without calculate quantity. * * @return array */ @@ -1429,9 +1430,9 @@ public function get_order_items( WC_Order $order, bool $only_not_settled = false $price = OrderCapture::get_item_price( $order_item, $order ); $tax_percent = $price['tax_percent']; - if($skipt_order_line){ + if ( $skipt_order_line ) { $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ), 2 ); - }else{ + } else { $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ) / $order_item->get_quantity(), 2 ); } From f33b591100a9344a569769ba2e21728354534550 Mon Sep 17 00:00:00 2001 From: Pond Date: Wed, 28 Aug 2024 09:56:14 +0700 Subject: [PATCH 3/4] Fix standard code and variable name --- includes/Gateways/ReepayGateway.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/Gateways/ReepayGateway.php b/includes/Gateways/ReepayGateway.php index 421a883e..6d779ddf 100644 --- a/includes/Gateways/ReepayGateway.php +++ b/includes/Gateways/ReepayGateway.php @@ -1397,11 +1397,11 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) { * * @param WC_Order $order order to get items. * @param bool $only_not_settled get only not settled items. - * @param bool $skipt_order_line get item price without calculate quantity. + * @param bool $skip_order_line get item price without calculate quantity. * * @return array */ - public function get_order_items( WC_Order $order, bool $only_not_settled = false, $skipt_order_line = false ): array { + public function get_order_items( WC_Order $order, bool $only_not_settled = false, $skip_order_line = false ): array { $prices_incl_tax = wc_prices_include_tax(); $items = array(); @@ -1430,7 +1430,11 @@ public function get_order_items( WC_Order $order, bool $only_not_settled = false $price = OrderCapture::get_item_price( $order_item, $order ); $tax_percent = $price['tax_percent']; - if ( $skipt_order_line ) { + if ( $tax_percent > 0 ) { + $prices_incl_tax = true; + } + + if ( $skip_order_line ) { $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ), 2 ); } else { $unit_price = round( ( $prices_incl_tax ? $price['subtotal_with_tax'] : $price['subtotal'] ) / $order_item->get_quantity(), 2 ); From e1be843418cbeaed00c1326b0a8cf0b212af4238 Mon Sep 17 00:00:00 2001 From: Pond Date: Wed, 28 Aug 2024 10:01:35 +0700 Subject: [PATCH 4/4] Update version 1.7.8.1 and changelog --- Readme.txt | 5 ++++- reepay-woocommerce-payment.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Readme.txt b/Readme.txt index 74044322..b56255e3 100755 --- a/Readme.txt +++ b/Readme.txt @@ -4,7 +4,7 @@ Tags: billwerk+, visa, mastercard, dankort, mobilepay Requires at least: 4.0 Tested up to: 6.6.1 Requires PHP: 7.4 -Stable tag: 1.7.8 +Stable tag: 1.7.8.1 License: GPL License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html @@ -18,6 +18,9 @@ The Billwerk+ Pay plugin extends WooCommerce allowing you to take payments on yo See installation guide right here: https://docu.billwerk.plus/help/en/apps/woocommerce/setup-woocommerce-plugin.html == Changelog == +v 1.7.8.1 - +* [Fix] - Fixed total calculation missing multiplication with number of items when using setting "Skip order lines" + v 1.7.8 - * [Fix] - Bug WP warning message "The use statement with non-compound name WC_Reepay_Renewals has no effect." (hotfix 1.7.7.1). * [Fix] - Bug double amount calculated when using setting "skip order lines" (hotfix 1.7.7.2). diff --git a/reepay-woocommerce-payment.php b/reepay-woocommerce-payment.php index 89b6b6ee..e5734733 100755 --- a/reepay-woocommerce-payment.php +++ b/reepay-woocommerce-payment.php @@ -4,7 +4,7 @@ * Description: Get a plug-n-play payment solution for WooCommerce, that is easy to use, highly secure and is built to maximize the potential of your e-commerce. * Author: Billwerk+ * Author URI: http://billwerk.plus - * Version: 1.7.8 + * Version: 1.7.8.1 * Text Domain: reepay-checkout-gateway * Domain Path: /languages * WC requires at least: 3.0.0