Changeset 3409597
- Timestamp:
- 12/03/2025 01:50:46 PM (4 months ago)
- Location:
- svea-checkout-for-woocommerce
- Files:
-
- 5 edited
- 18 copied
-
tags/3.4.1 (copied) (copied from svea-checkout-for-woocommerce/trunk)
-
tags/3.4.1/assets/css/backend (copied) (copied from svea-checkout-for-woocommerce/trunk/assets/css/backend)
-
tags/3.4.1/inc/Admin.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Admin.php)
-
tags/3.4.1/inc/Models/Svea_Checkout.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Models/Svea_Checkout.php)
-
tags/3.4.1/inc/Models/Svea_Item.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Models/Svea_Item.php) (1 diff)
-
tags/3.4.1/inc/Rule_Integration.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Rule_Integration.php)
-
tags/3.4.1/inc/Scripts.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Scripts.php)
-
tags/3.4.1/inc/Template_Handler.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Template_Handler.php)
-
tags/3.4.1/inc/WC_Gateway_Svea_Checkout.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/WC_Gateway_Svea_Checkout.php) (3 diffs)
-
tags/3.4.1/inc/Webhook_Handler.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/Webhook_Handler.php) (3 diffs)
-
tags/3.4.1/inc/settings-svea-checkout.php (copied) (copied from svea-checkout-for-woocommerce/trunk/inc/settings-svea-checkout.php)
-
tags/3.4.1/languages/svea-checkout-for-woocommerce-sv_SE.mo (copied) (copied from svea-checkout-for-woocommerce/trunk/languages/svea-checkout-for-woocommerce-sv_SE.mo)
-
tags/3.4.1/languages/svea-checkout-for-woocommerce-sv_SE.po (copied) (copied from svea-checkout-for-woocommerce/trunk/languages/svea-checkout-for-woocommerce-sv_SE.po)
-
tags/3.4.1/readme.txt (copied) (copied from svea-checkout-for-woocommerce/trunk/readme.txt) (3 diffs)
-
tags/3.4.1/svea-checkout-for-woocommerce.php (copied) (copied from svea-checkout-for-woocommerce/trunk/svea-checkout-for-woocommerce.php) (2 diffs)
-
tags/3.4.1/templates/backend/metabox.php (copied) (copied from svea-checkout-for-woocommerce/trunk/templates/backend/metabox.php)
-
tags/3.4.1/vendor/composer/autoload_classmap.php (copied) (copied from svea-checkout-for-woocommerce/trunk/vendor/composer/autoload_classmap.php)
-
tags/3.4.1/vendor/composer/autoload_static.php (copied) (copied from svea-checkout-for-woocommerce/trunk/vendor/composer/autoload_static.php)
-
trunk/inc/Models/Svea_Item.php (modified) (1 diff)
-
trunk/inc/WC_Gateway_Svea_Checkout.php (modified) (3 diffs)
-
trunk/inc/Webhook_Handler.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/svea-checkout-for-woocommerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
svea-checkout-for-woocommerce/tags/3.4.1/inc/Models/Svea_Item.php
r3393639 r3409597 190 190 $total_tax = array_sum( $shipping->get_taxes() ); 191 191 192 $unit_price = ( floatval( $shipping->get_cost() ) + $total_tax);192 $unit_price = round( ( floatval( $shipping->get_cost() ) + $total_tax ), 2 ); 193 193 194 194 // Prevent division by 0 195 195 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 ); 197 204 } 198 205 -
svea-checkout-for-woocommerce/tags/3.4.1/inc/WC_Gateway_Svea_Checkout.php
r3398960 r3409597 1454 1454 1455 1455 $has_error = false; 1456 $is_nshift_order = false; 1456 1457 1457 1458 // Map row ID's in Svea to WooCommerce … … 1465 1466 if ( $svea_row_number !== false ) { 1466 1467 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 } 1467 1473 1468 1474 $item->update_meta_data( '_svea_co_order_row_id', $svea_row_number ); … … 1474 1480 1475 1481 $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 ] ); 1476 1491 } 1477 1492 } -
svea-checkout-for-woocommerce/tags/3.4.1/inc/Webhook_Handler.php
r3398960 r3409597 281 281 $item_mapping = $wc_order->get_meta( '_svea_co_cart_mapping' ); 282 282 283 $is_nshift_order = false; 283 284 // Map row ID's in Svea to WooCommerce 284 285 if ( ! empty( $wc_order ) && is_array( $item_mapping ) ) { … … 291 292 if ( $svea_row_number !== false ) { 292 293 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 } 293 299 294 300 $item->delete_meta_data( '_svea_co_cart_key' ); … … 297 303 $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 298 304 $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 ] ); 299 314 } 300 315 } -
svea-checkout-for-woocommerce/tags/3.4.1/readme.txt
r3398960 r3409597 10 10 License: Apache 2.0 11 11 License URI: https://www.apache.org/licenses/LICENSE-2.0 12 Stable tag: 3.4. 012 Stable tag: 3.4.1 13 13 14 14 Supercharge your WooCommerce Store with powerful features to pay via Svea Checkout! … … 91 91 == Upgrade Notice == 92 92 93 = 3.4.1 = 94 3.4.1 is a patch release 95 93 96 = 3.4.0 = 94 97 3.4.0 is a minor release … … 411 414 412 415 == 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. 413 420 414 421 = 3.4.0 2025-11-19 = -
svea-checkout-for-woocommerce/tags/3.4.1/svea-checkout-for-woocommerce.php
r3398960 r3409597 14 14 * Plugin URI: https://wordpress.org/plugins/svea-checkout-for-woocommerce/ 15 15 * Description: Process payments in WooCommerce via Svea Checkout. 16 * Version: 3.4. 016 * Version: 3.4.1 17 17 * Requires Plugins: woocommerce 18 18 * Author: The Generation AB … … 47 47 * Version of plugin 48 48 */ 49 const VERSION = '3.4. 0';49 const VERSION = '3.4.1'; 50 50 51 51 /** -
svea-checkout-for-woocommerce/trunk/inc/Models/Svea_Item.php
r3393639 r3409597 190 190 $total_tax = array_sum( $shipping->get_taxes() ); 191 191 192 $unit_price = ( floatval( $shipping->get_cost() ) + $total_tax);192 $unit_price = round( ( floatval( $shipping->get_cost() ) + $total_tax ), 2 ); 193 193 194 194 // Prevent division by 0 195 195 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 ); 197 204 } 198 205 -
svea-checkout-for-woocommerce/trunk/inc/WC_Gateway_Svea_Checkout.php
r3398960 r3409597 1454 1454 1455 1455 $has_error = false; 1456 $is_nshift_order = false; 1456 1457 1457 1458 // Map row ID's in Svea to WooCommerce … … 1465 1466 if ( $svea_row_number !== false ) { 1466 1467 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 } 1467 1473 1468 1474 $item->update_meta_data( '_svea_co_order_row_id', $svea_row_number ); … … 1474 1480 1475 1481 $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 ] ); 1476 1491 } 1477 1492 } -
svea-checkout-for-woocommerce/trunk/inc/Webhook_Handler.php
r3398960 r3409597 281 281 $item_mapping = $wc_order->get_meta( '_svea_co_cart_mapping' ); 282 282 283 $is_nshift_order = false; 283 284 // Map row ID's in Svea to WooCommerce 284 285 if ( ! empty( $wc_order ) && is_array( $item_mapping ) ) { … … 291 292 if ( $svea_row_number !== false ) { 292 293 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 } 293 299 294 300 $item->delete_meta_data( '_svea_co_cart_key' ); … … 297 303 $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 298 304 $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 ] ); 299 314 } 300 315 } -
svea-checkout-for-woocommerce/trunk/readme.txt
r3398960 r3409597 10 10 License: Apache 2.0 11 11 License URI: https://www.apache.org/licenses/LICENSE-2.0 12 Stable tag: 3.4. 012 Stable tag: 3.4.1 13 13 14 14 Supercharge your WooCommerce Store with powerful features to pay via Svea Checkout! … … 91 91 == Upgrade Notice == 92 92 93 = 3.4.1 = 94 3.4.1 is a patch release 95 93 96 = 3.4.0 = 94 97 3.4.0 is a minor release … … 411 414 412 415 == 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. 413 420 414 421 = 3.4.0 2025-11-19 = -
svea-checkout-for-woocommerce/trunk/svea-checkout-for-woocommerce.php
r3398960 r3409597 14 14 * Plugin URI: https://wordpress.org/plugins/svea-checkout-for-woocommerce/ 15 15 * Description: Process payments in WooCommerce via Svea Checkout. 16 * Version: 3.4. 016 * Version: 3.4.1 17 17 * Requires Plugins: woocommerce 18 18 * Author: The Generation AB … … 47 47 * Version of plugin 48 48 */ 49 const VERSION = '3.4. 0';49 const VERSION = '3.4.1'; 50 50 51 51 /**
Note: See TracChangeset
for help on using the changeset viewer.