Skip to content

Commit

Permalink
Merge pull request #341 from reepay/pre-1.7.8.1
Browse files Browse the repository at this point in the history
v1.7.8.1
- Fixed total calculation missing multiplication with number of items when using setting "Skip order lines"
  • Loading branch information
ponddeja authored Aug 28, 2024
2 parents d2e8c49 + e1be843 commit 075f47f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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).
Expand Down
15 changes: 12 additions & 3 deletions includes/Gateways/ReepayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -1397,10 +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 $skip_order_line get item price without calculate quantity.
*
* @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, $skip_order_line = false ): array {
$prices_incl_tax = wc_prices_include_tax();

$items = array();
Expand Down Expand Up @@ -1429,7 +1430,15 @@ 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 ( $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 );
}

if ( $only_not_settled && ! empty( $order_item->get_meta( 'settled' ) ) ) {
continue;
Expand Down Expand Up @@ -1568,7 +1577,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 ) {
Expand Down
2 changes: 1 addition & 1 deletion reepay-woocommerce-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 075f47f

Please sign in to comment.