From 794d1d40667629b5ac893c9878525506f08c5b2b Mon Sep 17 00:00:00 2001 From: Marcus Dahl Date: Thu, 21 Sep 2023 09:56:33 +0200 Subject: [PATCH] fix: fixes #77 - refunds could not be processed properly because of a mistake when calling the `woocommerce_order_after_calculate_totals` action. We assume the object is always a subscription, when it is not --- README.txt | 3 +++ includes/wc-gateway-vipps-recurring.php | 8 +++++--- woo-vipps-recurring.php | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index 51985c3..01cbb52 100755 --- a/README.txt +++ b/README.txt @@ -160,6 +160,9 @@ Alternatively you could look into using WooCommerce "Early renewals": [https://d == Changelog == += 1.16.5 = +* Fixed: Refunds could not be processed properly because of a mistake when calling the `woocommerce_order_after_calculate_totals` action. We assume the object is always a subscription, when it is not. + = 1.16.4 = * Fixed: Properly stop checking for a gateway change when a gateway change succeeded. diff --git a/includes/wc-gateway-vipps-recurring.php b/includes/wc-gateway-vipps-recurring.php index e27a1ef..adbad1b 100755 --- a/includes/wc-gateway-vipps-recurring.php +++ b/includes/wc-gateway-vipps-recurring.php @@ -2039,10 +2039,12 @@ public function prevent_backwards_transition_on_completed_order( $status, $order } public function update_agreement_price_in_app( $and_taxes, $subscription ) { - $payment_method = WC_Vipps_Recurring_Helper::get_payment_method( $subscription ); + if ( ! wcs_is_subscription( $subscription ) ) { + return; + } - if ( $this->id !== $payment_method - || ! wcs_is_subscription( $subscription ) ) { + $payment_method = WC_Vipps_Recurring_Helper::get_payment_method( $subscription ); + if ( $this->id !== $payment_method ) { return; } diff --git a/woo-vipps-recurring.php b/woo-vipps-recurring.php index e21cb1d..c45b78d 100755 --- a/woo-vipps-recurring.php +++ b/woo-vipps-recurring.php @@ -5,7 +5,7 @@ * Description: Offer recurring payments with Vipps for WooCommerce Subscriptions * Author: Everyday AS * Author URI: https://everyday.no - * Version: 1.16.4 + * Version: 1.16.5 * Requires at least: 4.4 * Tested up to: 6.3 * WC tested up to: 8.0 @@ -17,7 +17,7 @@ // phpcs:disable WordPress.Files.FileName -define( 'WC_VIPPS_RECURRING_VERSION', '1.16.4' ); +define( 'WC_VIPPS_RECURRING_VERSION', '1.16.5' ); add_action( 'plugins_loaded', 'woocommerce_gateway_vipps_recurring_init' );