Plugin Directory

Changeset 3321574


Ignore:
Timestamp:
07/03/2025 07:18:57 AM (8 months ago)
Author:
inpost
Message:

Version 1.0.1

Location:
inpost-international/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inpost-international/trunk/changelog.txt

    r3291728 r3321574  
    33## [1.0.0] - 2025-05-12
    44### Initial commit
    5 -
     5
     6
     7## [1.0.1] - 2025-07-03
     8### Fix
     9- calculating of product dimensions
  • inpost-international/trunk/inpost-international.php

    r3291728 r3321574  
    55 * Description: InPost International to oficjalna bezpłatna aplikacja InPost dla obsługi międzynarodowej dostawy
    66 * Tags: woocommerce, inpost, shipments
    7  * Version: 1.0.0
     7 * Version: 1.0.1
    88 * Tested up to: 6.8
    99 * Requires PHP: 7.4
     
    3636}
    3737
    38 define( 'INPOST_INTL_PLUGIN_VERSION', '1.0.0' );
     38define( 'INPOST_INTL_PLUGIN_VERSION', '1.0.1' );
    3939define( 'INPOST_INTL_PLUGIN_SLUG', 'inpost_international' );
    4040define( 'INPOST_INTL_PLUGIN_FILE', __FILE__ );
  • inpost-international/trunk/readme.txt

    r3291728 r3321574  
    44Requires at least: 6.0
    55Tested up to: 6.8
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77Requires PHP: 7.4
    88License: GPLv3 or later
     
    7373== Changelog ==
    7474
     75= 1.0.1 =
     76* Fix: calculating of product dimensions
     77
    7578= 1.0.0 =
    7679* wstępne wydanie.
  • inpost-international/trunk/src/Helpers/Helper.php

    r3291728 r3321574  
    617617    public function calculate_multiple_products_dimensions( $items ) {
    618618
     619        $calculated_length = 0;
     620        $calculated_width  = 0;
     621        $calculated_height = 0;
     622
    619623        $total_weight = 0;
    620624        $total_volume = 0;
     
    640644
    641645        // Calculate dimensions to fit within 64x41x38 cm box.
    642         $box_volume   = 64 * 39 * 38;
    643         $scale_factor = min( 1, $box_volume / $total_volume );
    644 
    645         $calculated_length = min( 64, $max_length * $scale_factor );
    646         $calculated_width  = min( 41, $max_width * $scale_factor );
    647         $calculated_height = $total_volume / ( $calculated_length * $calculated_width );
    648 
    649         // Ensure height doesn't exceed 38 cm.
    650         if ( $calculated_height > 38 ) {
    651             $calculated_height = 38;
    652             $calculated_width  = min( 39, sqrt( $total_volume / ( 38 * $calculated_length ) ) );
    653             $calculated_length = $total_volume / ( 38 * $calculated_width );
     646        $box_volume = 64 * 39 * 38;
     647        if ( $total_volume > 0 ) {
     648            $scale_factor = min( 1, $box_volume / $total_volume );
     649
     650            $calculated_length = min( 64, $max_length * $scale_factor );
     651            $calculated_width  = min( 41, $max_width * $scale_factor );
     652
     653            if ( $calculated_length > 0 && $calculated_width > 0 ) {
     654                $calculated_height = $total_volume / ( $calculated_length * $calculated_width );
     655
     656                // Ensure height doesn't exceed 38 cm.
     657                if ( $calculated_height > 38 ) {
     658                    $calculated_height = 38;
     659                    $calculated_width  = min( 39, sqrt( $total_volume / ( 38 * $calculated_length ) ) );
     660                    $calculated_length = $total_volume / ( 38 * $calculated_width );
     661                }
     662            }
    654663        }
    655664
Note: See TracChangeset for help on using the changeset viewer.