diff --git a/README.txt b/README.txt index b9159af..df59c1e 100755 --- a/README.txt +++ b/README.txt @@ -158,6 +158,10 @@ Alternatively you could look into using WooCommerce "Early renewals": [https://d ==== End Log ==== += 1.12.3 = +* Fixed: Initial charge description no longer contains " + " when no extra products are purchased. +* Fixed: Filling in 0 in the trial field tricking us into adding a campaign to the product, also resulting in an empty `initialCharge.description` and being unable to check out. + = 1.12.2 = * Fixed: Fixed an issue where `initialCharge.description` was empty. It cannot be empty under any circumstances. diff --git a/includes/wc-gateway-vipps-recurring.php b/includes/wc-gateway-vipps-recurring.php index e175635..8e92e68 100755 --- a/includes/wc-gateway-vipps-recurring.php +++ b/includes/wc-gateway-vipps-recurring.php @@ -1471,16 +1471,20 @@ public function process_payment( $order_id, bool $retry = true, bool $previous_e $is_zero_amount = (int) $order->get_total() === 0 || $is_gateway_change; $capture_immediately = $is_virtual || $direct_capture; $has_synced_product = WC_Subscriptions_Synchroniser::subscription_contains_synced_product( $subscription ); - $has_trial = WC_Subscriptions_Product::get_trial_length( $product ) !== null; + $has_trial = (bool) WC_Subscriptions_Product::get_trial_length( $product ); $sign_up_fee = WC_Subscriptions_Order::get_sign_up_fee( $order ); $has_campaign = $has_trial || $has_synced_product || $is_zero_amount || $order->get_total_discount() !== 0.00 || $is_subscription_switch || $sign_up_fee; $has_free_campaign = $is_subscription_switch || $sign_up_fee || $has_synced_product || $has_trial; if ( ! $is_zero_amount ) { - $initial_charge_description = WC_Vipps_Recurring_Helper::get_product_description( $parent_product ) . ' + ' . $extra_initial_charge_description; - if ( $has_campaign && ! empty( $extra_initial_charge_description ) ) { - $initial_charge_description = $extra_initial_charge_description; + $initial_charge_description = WC_Vipps_Recurring_Helper::get_product_description( $parent_product ); + if ( ! empty( $extra_initial_charge_description ) ) { + $initial_charge_description .= ' + ' . $extra_initial_charge_description; + + if ( $has_campaign ) { + $initial_charge_description = $extra_initial_charge_description; + } } $agreement_body = array_merge( $agreement_body, [ diff --git a/includes/wc-vipps-recurring-api.php b/includes/wc-vipps-recurring-api.php index e8c2ae8..0966c06 100755 --- a/includes/wc-vipps-recurring-api.php +++ b/includes/wc-vipps-recurring-api.php @@ -106,11 +106,12 @@ private function process_agreement_body( $body ): array { } } - if ( isset( $body['initialCharge']['description'] ) ) { + if ( isset( $body['initialCharge'] ) ) { $charge_description = ! empty( $body['initialCharge']['description'] ) ? $body['initialCharge']['description'] : 'Mangler produktbeskrivelse'; + $body['initialCharge']['description'] = $charge_description; if ( strlen( $charge_description ) > 45 ) { $body['initialCharge']['description'] = mb_substr( $charge_description, 0, 42 ) . '...'; } diff --git a/woo-vipps-recurring.php b/woo-vipps-recurring.php index 554f020..6612b30 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.12.2 + * Version: 1.12.3 * Requires at least: 4.4 * Tested up to: 5.8 * WC tested up to: 6.0 @@ -17,7 +17,7 @@ // phpcs:disable WordPress.Files.FileName -define( 'WC_VIPPS_RECURRING_VERSION', '1.12.2' ); +define( 'WC_VIPPS_RECURRING_VERSION', '1.12.3' ); add_action( 'plugins_loaded', 'woocommerce_gateway_vipps_recurring_init' );