Plugin Directory

Changeset 3409597


Ignore:
Timestamp:
12/03/2025 01:50:46 PM (4 months ago)
Author:
thegeneration
Message:

Tagging version 3.4.1

Location:
svea-checkout-for-woocommerce
Files:
5 edited
18 copied

Legend:

Unmodified
Added
Removed
  • svea-checkout-for-woocommerce/tags/3.4.1/inc/Models/Svea_Item.php

    r3393639 r3409597  
    190190        $total_tax = array_sum( $shipping->get_taxes() );
    191191
    192         $unit_price = ( floatval( $shipping->get_cost() ) + $total_tax );
     192        $unit_price = round( ( floatval( $shipping->get_cost() ) + $total_tax ), 2 );
    193193
    194194        // Prevent division by 0
    195195        if ( $shipping->get_cost() > 0 ) {
    196             $tax_percentage = ( $total_tax / (float) $shipping->get_cost() ) * 100;
     196            $tax_percentages = array_map(
     197                function( $tax_rate_id ) {
     198                    return WC_Tax::get_rate_percent_value( $tax_rate_id );
     199                },
     200                array_keys( $shipping->get_taxes() )
     201            );
     202
     203            $tax_percentage = array_reduce( $tax_percentages, fn ( $sum, $rate ) => $sum + $rate, 0.0 );
    197204        }
    198205
  • svea-checkout-for-woocommerce/tags/3.4.1/inc/WC_Gateway_Svea_Checkout.php

    r3398960 r3409597  
    14541454
    14551455        $has_error = false;
     1456        $is_nshift_order = false;
    14561457
    14571458        // Map row ID's in Svea to WooCommerce
     
    14651466                if ( $svea_row_number !== false ) {
    14661467                    unset( $item_mapping[ $svea_row_number ] );
     1468
     1469                    // Check if it's a nshift item
     1470                    if ( strpos( $key, '_svea_nshift' ) !== false ) {
     1471                        $is_nshift_order = true;
     1472                    }
    14671473
    14681474                    $item->update_meta_data( '_svea_co_order_row_id', $svea_row_number );
     
    14741480
    14751481                    $has_error = true;
     1482                }
     1483            }
     1484        }
     1485
     1486        if ( $is_nshift_order ) {
     1487            // Remove any other nshift items that could be present (from different tax rates)
     1488            foreach ( $item_mapping as $svea_row_number => $key ) {
     1489                if ( strpos( $key, '_svea_nshift' ) !== false ) {
     1490                    unset( $item_mapping[ $svea_row_number ] );
    14761491                }
    14771492            }
  • svea-checkout-for-woocommerce/tags/3.4.1/inc/Webhook_Handler.php

    r3398960 r3409597  
    281281            $item_mapping = $wc_order->get_meta( '_svea_co_cart_mapping' );
    282282
     283            $is_nshift_order = false;
    283284            // Map row ID's in Svea to WooCommerce
    284285            if ( ! empty( $wc_order ) && is_array( $item_mapping ) ) {
     
    291292                    if ( $svea_row_number !== false ) {
    292293                        unset( $item_mapping[ $svea_row_number ] );
     294
     295                        // Check if it's a nshift item
     296                        if ( strpos( $key, '_svea_nshift' ) !== false ) {
     297                            $is_nshift_order = true;
     298                        }
    293299
    294300                        $item->delete_meta_data( '_svea_co_cart_key' );
     
    297303                        $this->gateway::log( sprintf( 'Item mapping missmatch. Svea Order ID: %s. WC-ID: %s. Item without match: %s', $this->svea_order_id, $wc_order->get_id(), $key ), 'error' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
    298304                        $has_error = true;
     305                    }
     306                }
     307            }
     308
     309            if ( $is_nshift_order ) {
     310                // Remove any other nshift items that could be present (from different tax rates)
     311                foreach ( $item_mapping as $svea_row_number => $key ) {
     312                    if ( strpos( $key, '_svea_nshift' ) !== false ) {
     313                        unset( $item_mapping[ $svea_row_number ] );
    299314                    }
    300315                }
  • svea-checkout-for-woocommerce/tags/3.4.1/readme.txt

    r3398960 r3409597  
    1010License: Apache 2.0
    1111License URI: https://www.apache.org/licenses/LICENSE-2.0
    12 Stable tag: 3.4.0
     12Stable tag: 3.4.1
    1313
    1414Supercharge your WooCommerce Store with powerful features to pay via Svea Checkout!
     
    9191== Upgrade Notice ==
    9292
     93= 3.4.1 =
     943.4.1 is a patch release
     95
    9396= 3.4.0 =
    94973.4.0 is a minor release
     
    411414
    412415== Changelog ==
     416
     417= 3.4.1 2025-12-03 =
     418- Better handling of nShift order rows when syncing order items from Svea to WooCommerce to prevent issues with tax rates.
     419- Improved retrieval of tax rate for shipping to avoid rounding issues when the cost is low.
    413420
    414421= 3.4.0 2025-11-19 =
  • svea-checkout-for-woocommerce/tags/3.4.1/svea-checkout-for-woocommerce.php

    r3398960 r3409597  
    1414 * Plugin URI: https://wordpress.org/plugins/svea-checkout-for-woocommerce/
    1515 * Description: Process payments in WooCommerce via Svea Checkout.
    16  * Version: 3.4.0
     16 * Version: 3.4.1
    1717 * Requires Plugins: woocommerce
    1818 * Author: The Generation AB
     
    4747         * Version of plugin
    4848         */
    49         const VERSION = '3.4.0';
     49        const VERSION = '3.4.1';
    5050
    5151        /**
  • svea-checkout-for-woocommerce/trunk/inc/Models/Svea_Item.php

    r3393639 r3409597  
    190190        $total_tax = array_sum( $shipping->get_taxes() );
    191191
    192         $unit_price = ( floatval( $shipping->get_cost() ) + $total_tax );
     192        $unit_price = round( ( floatval( $shipping->get_cost() ) + $total_tax ), 2 );
    193193
    194194        // Prevent division by 0
    195195        if ( $shipping->get_cost() > 0 ) {
    196             $tax_percentage = ( $total_tax / (float) $shipping->get_cost() ) * 100;
     196            $tax_percentages = array_map(
     197                function( $tax_rate_id ) {
     198                    return WC_Tax::get_rate_percent_value( $tax_rate_id );
     199                },
     200                array_keys( $shipping->get_taxes() )
     201            );
     202
     203            $tax_percentage = array_reduce( $tax_percentages, fn ( $sum, $rate ) => $sum + $rate, 0.0 );
    197204        }
    198205
  • svea-checkout-for-woocommerce/trunk/inc/WC_Gateway_Svea_Checkout.php

    r3398960 r3409597  
    14541454
    14551455        $has_error = false;
     1456        $is_nshift_order = false;
    14561457
    14571458        // Map row ID's in Svea to WooCommerce
     
    14651466                if ( $svea_row_number !== false ) {
    14661467                    unset( $item_mapping[ $svea_row_number ] );
     1468
     1469                    // Check if it's a nshift item
     1470                    if ( strpos( $key, '_svea_nshift' ) !== false ) {
     1471                        $is_nshift_order = true;
     1472                    }
    14671473
    14681474                    $item->update_meta_data( '_svea_co_order_row_id', $svea_row_number );
     
    14741480
    14751481                    $has_error = true;
     1482                }
     1483            }
     1484        }
     1485
     1486        if ( $is_nshift_order ) {
     1487            // Remove any other nshift items that could be present (from different tax rates)
     1488            foreach ( $item_mapping as $svea_row_number => $key ) {
     1489                if ( strpos( $key, '_svea_nshift' ) !== false ) {
     1490                    unset( $item_mapping[ $svea_row_number ] );
    14761491                }
    14771492            }
  • svea-checkout-for-woocommerce/trunk/inc/Webhook_Handler.php

    r3398960 r3409597  
    281281            $item_mapping = $wc_order->get_meta( '_svea_co_cart_mapping' );
    282282
     283            $is_nshift_order = false;
    283284            // Map row ID's in Svea to WooCommerce
    284285            if ( ! empty( $wc_order ) && is_array( $item_mapping ) ) {
     
    291292                    if ( $svea_row_number !== false ) {
    292293                        unset( $item_mapping[ $svea_row_number ] );
     294
     295                        // Check if it's a nshift item
     296                        if ( strpos( $key, '_svea_nshift' ) !== false ) {
     297                            $is_nshift_order = true;
     298                        }
    293299
    294300                        $item->delete_meta_data( '_svea_co_cart_key' );
     
    297303                        $this->gateway::log( sprintf( 'Item mapping missmatch. Svea Order ID: %s. WC-ID: %s. Item without match: %s', $this->svea_order_id, $wc_order->get_id(), $key ), 'error' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
    298304                        $has_error = true;
     305                    }
     306                }
     307            }
     308
     309            if ( $is_nshift_order ) {
     310                // Remove any other nshift items that could be present (from different tax rates)
     311                foreach ( $item_mapping as $svea_row_number => $key ) {
     312                    if ( strpos( $key, '_svea_nshift' ) !== false ) {
     313                        unset( $item_mapping[ $svea_row_number ] );
    299314                    }
    300315                }
  • svea-checkout-for-woocommerce/trunk/readme.txt

    r3398960 r3409597  
    1010License: Apache 2.0
    1111License URI: https://www.apache.org/licenses/LICENSE-2.0
    12 Stable tag: 3.4.0
     12Stable tag: 3.4.1
    1313
    1414Supercharge your WooCommerce Store with powerful features to pay via Svea Checkout!
     
    9191== Upgrade Notice ==
    9292
     93= 3.4.1 =
     943.4.1 is a patch release
     95
    9396= 3.4.0 =
    94973.4.0 is a minor release
     
    411414
    412415== Changelog ==
     416
     417= 3.4.1 2025-12-03 =
     418- Better handling of nShift order rows when syncing order items from Svea to WooCommerce to prevent issues with tax rates.
     419- Improved retrieval of tax rate for shipping to avoid rounding issues when the cost is low.
    413420
    414421= 3.4.0 2025-11-19 =
  • svea-checkout-for-woocommerce/trunk/svea-checkout-for-woocommerce.php

    r3398960 r3409597  
    1414 * Plugin URI: https://wordpress.org/plugins/svea-checkout-for-woocommerce/
    1515 * Description: Process payments in WooCommerce via Svea Checkout.
    16  * Version: 3.4.0
     16 * Version: 3.4.1
    1717 * Requires Plugins: woocommerce
    1818 * Author: The Generation AB
     
    4747         * Version of plugin
    4848         */
    49         const VERSION = '3.4.0';
     49        const VERSION = '3.4.1';
    5050
    5151        /**
Note: See TracChangeset for help on using the changeset viewer.