Plugin Directory

Changeset 3426854


Ignore:
Timestamp:
12/24/2025 01:01:35 PM (2 months ago)
Author:
jneshipping
Message:

Update to 1.4.1

Location:
jne-shipping-official
Files:
2 added
6 edited
34 copied

Legend:

Unmodified
Added
Removed
  • jne-shipping-official/tags/1.4.1/admin/class-jne-woocommerce-admin.php

    r3411298 r3426854  
    111111  private function load_dependencies()
    112112  {
     113    // Load weight helper first as it's used by multiple classes
     114    require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php';
    113115    require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-order-search-list.php';
    114116    require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-order-helper.php';
  • jne-shipping-official/tags/1.4.1/admin/includes/class-jne-admin-order-helper.php

    r3399074 r3426854  
    234234  /**
    235235   * Get order total weight.
    236    * @return int
     236   * Uses centralized weight helper for consistency and proper unit conversion.
     237   * Returns formatted weight for JNE API (number(3) - max 999 kg).
     238   *
     239   * @return int Formatted weight (0-999) for OLSHOP_WEIGHT
    237240   */
    238241  public function getOrderTotalWeight(): int
    239242  {
    240     if (!$this->order)
    241       return 0;
    242     $total_weight = 0;
    243     foreach ($this->order->get_items() as $item) {
    244       $product = $item->get_product();
    245       if ($product) {
    246         $weight = $product->get_weight();
    247         if ($weight) {
    248           $total_weight += $weight * $item->get_quantity();
    249         }
    250       }
    251     }
    252     return ceil($total_weight);
     243    if (!$this->order) {
     244      return 1; // Default minimum weight
     245    }
     246   
     247    // Load weight helper if not already loaded
     248    if (!class_exists('Jneshof_Weight_Helper')) {
     249      require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php';
     250    }
     251   
     252    return Jneshof_Weight_Helper::get_weight_for_cnote($this->order);
    253253  }
    254254
  • jne-shipping-official/tags/1.4.1/admin/includes/class-jne-admin-shipping-method.php

    r3426041 r3426854  
    88if (!class_exists('Jneshof_Admin_Shipping_Cost_Adjustment')) {
    99  require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-shipping-cost-adjustment.php';
     10}
     11
     12// Load weight helper if not already loaded (fallback)
     13if (!class_exists('Jneshof_Weight_Helper')) {
     14  require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php';
    1015}
    1116
     
    279284
    280285  /**
    281    * Convert weight to kilograms based on WooCommerce weight unit setting
    282    *
    283    * @param float $weight Weight value
    284    * @param string $from_unit Source unit (kg, g, lbs, oz)
    285    * @return float Weight in kilograms
    286    */
    287   private function convert_weight_to_kg($weight, $from_unit)
    288   {
    289     $from_unit = strtolower($from_unit);
    290    
    291     switch ($from_unit) {
    292       case 'kg':
    293         // Already in kilograms
    294         return floatval($weight);
    295        
    296       case 'g':
    297         // Convert grams to kilograms: 1 g = 0.001 kg
    298         return floatval($weight) * 0.001;
    299        
    300       case 'lbs':
    301         // Convert pounds to kilograms: 1 lb = 0.453592 kg
    302         return floatval($weight) * 0.453592;
    303        
    304       case 'oz':
    305         // Convert ounces to kilograms: 1 oz = 0.0283495 kg
    306         return floatval($weight) * 0.0283495;
    307        
    308       default:
    309         // Default to kilograms if unit is unknown
    310         return floatval($weight);
    311     }
    312   }
    313 
    314   /**
    315    * Get WooCommerce weight unit setting
    316    *
    317    * @return string Weight unit (kg, g, lbs, oz)
    318    */
    319   private function get_weight_unit()
    320   {
    321     // Get WooCommerce weight unit setting, default to 'kg'
    322     $weight_unit = get_option('woocommerce_weight_unit', 'kg');
    323    
    324     // Normalize unit to lowercase
    325     return strtolower($weight_unit);
    326   }
    327 
    328   /**
    329286   * Calculate total weight of package
     287   * Uses centralized weight helper for consistency
    330288   *
    331289   * @param array $package Package data
     
    334292  private function get_weight($package)
    335293  {
    336     $weight = 0;
    337     $weight_unit = $this->get_weight_unit();
    338    
    339     if (isset($package['contents']) && is_array($package['contents'])) {
    340       foreach ($package['contents'] as $item) {
    341         if (isset($item['data']) && is_object($item['data'])) {
    342           $product_weight = $item['data']->get_weight();
    343           $quantity = isset($item['quantity']) ? intval($item['quantity']) : 1;
    344          
    345           if ($product_weight && is_numeric($product_weight)) {
    346             // Product weight is in WooCommerce weight unit, convert to kg
    347             $weight_in_kg = $this->convert_weight_to_kg($product_weight, $weight_unit);
    348             $weight += $weight_in_kg * $quantity;
    349           }
    350         }
    351       }
    352     }
    353    
    354     // Return minimum 0.1kg if total weight is 0 or very small
    355     return max($weight, 0.1);
    356   }
    357 }
     294    return Jneshof_Weight_Helper::get_weight_for_shipping($package);
     295  }
     296}
  • jne-shipping-official/tags/1.4.1/composer.json

    r3426041 r3426854  
    22    "name": "jne-shipping/jne-shipping-official",
    33    "description": "WordPress plugin integrated with WooCommerce for JNE shipping services",
    4     "version": "1.4.0",
     4    "version": "1.4.1",
    55    "type": "wordpress-plugin",
    66    "license": "GPL-2.0+",
  • jne-shipping-official/tags/1.4.1/jne-shipping-official.php

    r3426041 r3426854  
    2020 * Plugin Name:       JNE Shipping Official
    2121 * Description:       WordPress plugin integrated with WooCommerce for JNE shipping services
    22  * Version:           1.4.0
     22 * Version:           1.4.1
    2323 * Author:            PT. Tiki Jalur Nugraha Ekakurir
    2424 * Author URI:        https://jne.co.id/
  • jne-shipping-official/tags/1.4.1/readme.txt

    r3426041 r3426854  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.4.0
     8Stable tag: 1.4.1
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    9090
    9191== Changelog ==
     92
     93= 1.4.1 =
     94* Added: Dimensional weight (volumetric weight) calculation - Weight calculation now compares real weight vs dimensional weight
     95* Formula: Dimensional weight = (length × width × height) / 6000
     96* Enhanced: Weight calculation uses the higher value between real weight and dimensional weight for shipping cost calculation
     97* Added: Automatic dimension unit conversion support (cm, m, in, yd, mm) based on WooCommerce dimension unit settings
     98* Improved: Shipping cost accuracy by considering both physical weight and package volume
     99* Fixed: Weight calculation now properly handles products with dimensions but no weight, and vice versa
    92100
    93101= 1.4.0 =
  • jne-shipping-official/trunk/admin/class-jne-woocommerce-admin.php

    r3411298 r3426854  
    111111  private function load_dependencies()
    112112  {
     113    // Load weight helper first as it's used by multiple classes
     114    require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php';
    113115    require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-order-search-list.php';
    114116    require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-order-helper.php';
  • jne-shipping-official/trunk/admin/includes/class-jne-admin-order-helper.php

    r3399074 r3426854  
    234234  /**
    235235   * Get order total weight.
    236    * @return int
     236   * Uses centralized weight helper for consistency and proper unit conversion.
     237   * Returns formatted weight for JNE API (number(3) - max 999 kg).
     238   *
     239   * @return int Formatted weight (0-999) for OLSHOP_WEIGHT
    237240   */
    238241  public function getOrderTotalWeight(): int
    239242  {
    240     if (!$this->order)
    241       return 0;
    242     $total_weight = 0;
    243     foreach ($this->order->get_items() as $item) {
    244       $product = $item->get_product();
    245       if ($product) {
    246         $weight = $product->get_weight();
    247         if ($weight) {
    248           $total_weight += $weight * $item->get_quantity();
    249         }
    250       }
    251     }
    252     return ceil($total_weight);
     243    if (!$this->order) {
     244      return 1; // Default minimum weight
     245    }
     246   
     247    // Load weight helper if not already loaded
     248    if (!class_exists('Jneshof_Weight_Helper')) {
     249      require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php';
     250    }
     251   
     252    return Jneshof_Weight_Helper::get_weight_for_cnote($this->order);
    253253  }
    254254
  • jne-shipping-official/trunk/admin/includes/class-jne-admin-shipping-method.php

    r3426041 r3426854  
    88if (!class_exists('Jneshof_Admin_Shipping_Cost_Adjustment')) {
    99  require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-shipping-cost-adjustment.php';
     10}
     11
     12// Load weight helper if not already loaded (fallback)
     13if (!class_exists('Jneshof_Weight_Helper')) {
     14  require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php';
    1015}
    1116
     
    279284
    280285  /**
    281    * Convert weight to kilograms based on WooCommerce weight unit setting
    282    *
    283    * @param float $weight Weight value
    284    * @param string $from_unit Source unit (kg, g, lbs, oz)
    285    * @return float Weight in kilograms
    286    */
    287   private function convert_weight_to_kg($weight, $from_unit)
    288   {
    289     $from_unit = strtolower($from_unit);
    290    
    291     switch ($from_unit) {
    292       case 'kg':
    293         // Already in kilograms
    294         return floatval($weight);
    295        
    296       case 'g':
    297         // Convert grams to kilograms: 1 g = 0.001 kg
    298         return floatval($weight) * 0.001;
    299        
    300       case 'lbs':
    301         // Convert pounds to kilograms: 1 lb = 0.453592 kg
    302         return floatval($weight) * 0.453592;
    303        
    304       case 'oz':
    305         // Convert ounces to kilograms: 1 oz = 0.0283495 kg
    306         return floatval($weight) * 0.0283495;
    307        
    308       default:
    309         // Default to kilograms if unit is unknown
    310         return floatval($weight);
    311     }
    312   }
    313 
    314   /**
    315    * Get WooCommerce weight unit setting
    316    *
    317    * @return string Weight unit (kg, g, lbs, oz)
    318    */
    319   private function get_weight_unit()
    320   {
    321     // Get WooCommerce weight unit setting, default to 'kg'
    322     $weight_unit = get_option('woocommerce_weight_unit', 'kg');
    323    
    324     // Normalize unit to lowercase
    325     return strtolower($weight_unit);
    326   }
    327 
    328   /**
    329286   * Calculate total weight of package
     287   * Uses centralized weight helper for consistency
    330288   *
    331289   * @param array $package Package data
     
    334292  private function get_weight($package)
    335293  {
    336     $weight = 0;
    337     $weight_unit = $this->get_weight_unit();
    338    
    339     if (isset($package['contents']) && is_array($package['contents'])) {
    340       foreach ($package['contents'] as $item) {
    341         if (isset($item['data']) && is_object($item['data'])) {
    342           $product_weight = $item['data']->get_weight();
    343           $quantity = isset($item['quantity']) ? intval($item['quantity']) : 1;
    344          
    345           if ($product_weight && is_numeric($product_weight)) {
    346             // Product weight is in WooCommerce weight unit, convert to kg
    347             $weight_in_kg = $this->convert_weight_to_kg($product_weight, $weight_unit);
    348             $weight += $weight_in_kg * $quantity;
    349           }
    350         }
    351       }
    352     }
    353    
    354     // Return minimum 0.1kg if total weight is 0 or very small
    355     return max($weight, 0.1);
    356   }
    357 }
     294    return Jneshof_Weight_Helper::get_weight_for_shipping($package);
     295  }
     296}
  • jne-shipping-official/trunk/composer.json

    r3426041 r3426854  
    22    "name": "jne-shipping/jne-shipping-official",
    33    "description": "WordPress plugin integrated with WooCommerce for JNE shipping services",
    4     "version": "1.4.0",
     4    "version": "1.4.1",
    55    "type": "wordpress-plugin",
    66    "license": "GPL-2.0+",
  • jne-shipping-official/trunk/jne-shipping-official.php

    r3426041 r3426854  
    2020 * Plugin Name:       JNE Shipping Official
    2121 * Description:       WordPress plugin integrated with WooCommerce for JNE shipping services
    22  * Version:           1.4.0
     22 * Version:           1.4.1
    2323 * Author:            PT. Tiki Jalur Nugraha Ekakurir
    2424 * Author URI:        https://jne.co.id/
  • jne-shipping-official/trunk/readme.txt

    r3426041 r3426854  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.4.0
     8Stable tag: 1.4.1
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    9090
    9191== Changelog ==
     92
     93= 1.4.1 =
     94* Added: Dimensional weight (volumetric weight) calculation - Weight calculation now compares real weight vs dimensional weight
     95* Formula: Dimensional weight = (length × width × height) / 6000
     96* Enhanced: Weight calculation uses the higher value between real weight and dimensional weight for shipping cost calculation
     97* Added: Automatic dimension unit conversion support (cm, m, in, yd, mm) based on WooCommerce dimension unit settings
     98* Improved: Shipping cost accuracy by considering both physical weight and package volume
     99* Fixed: Weight calculation now properly handles products with dimensions but no weight, and vice versa
    92100
    93101= 1.4.0 =
Note: See TracChangeset for help on using the changeset viewer.