Changeset 3426854
- Timestamp:
- 12/24/2025 01:01:35 PM (2 months ago)
- Location:
- jne-shipping-official
- Files:
-
- 2 added
- 6 edited
- 34 copied
-
tags/1.4.1 (copied) (copied from jne-shipping-official/trunk)
-
tags/1.4.1/LICENSE.txt (copied) (copied from jne-shipping-official/trunk/LICENSE.txt)
-
tags/1.4.1/admin (copied) (copied from jne-shipping-official/trunk/admin)
-
tags/1.4.1/admin/class-jne-woocommerce-admin.php (copied) (copied from jne-shipping-official/trunk/admin/class-jne-woocommerce-admin.php) (1 diff)
-
tags/1.4.1/admin/includes/class-jne-admin-dashboard.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-dashboard.php)
-
tags/1.4.1/admin/includes/class-jne-admin-generate-awb.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-generate-awb.php)
-
tags/1.4.1/admin/includes/class-jne-admin-generate-cnote.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-generate-cnote.php)
-
tags/1.4.1/admin/includes/class-jne-admin-order-helper.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-order-helper.php) (1 diff)
-
tags/1.4.1/admin/includes/class-jne-admin-order-list.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-order-list.php)
-
tags/1.4.1/admin/includes/class-jne-admin-shipping-cost-adjustment.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-shipping-cost-adjustment.php)
-
tags/1.4.1/admin/includes/class-jne-admin-shipping-method.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-shipping-method.php) (3 diffs)
-
tags/1.4.1/admin/includes/class-jne-weight-helper.php (added)
-
tags/1.4.1/admin/partials/jne-woocommerce-admin-dashboard-display.php (copied) (copied from jne-shipping-official/trunk/admin/partials/jne-woocommerce-admin-dashboard-display.php)
-
tags/1.4.1/admin/partials/jne-woocommerce-admin-shipping-cost-adjustments-display.php (copied) (copied from jne-shipping-official/trunk/admin/partials/jne-woocommerce-admin-shipping-cost-adjustments-display.php)
-
tags/1.4.1/admin/partials/jne-woocommerce-admin-support-display.php (copied) (copied from jne-shipping-official/trunk/admin/partials/jne-woocommerce-admin-support-display.php)
-
tags/1.4.1/admin/partials/jne-woocommerce-admin-webhook-logs-display.php (copied) (copied from jne-shipping-official/trunk/admin/partials/jne-woocommerce-admin-webhook-logs-display.php)
-
tags/1.4.1/assets (copied) (copied from jne-shipping-official/trunk/assets)
-
tags/1.4.1/composer.json (copied) (copied from jne-shipping-official/trunk/composer.json) (1 diff)
-
tags/1.4.1/composer.lock (copied) (copied from jne-shipping-official/trunk/composer.lock)
-
tags/1.4.1/includes (copied) (copied from jne-shipping-official/trunk/includes)
-
tags/1.4.1/includes/class-jne-woocommerce-api.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce-api.php)
-
tags/1.4.1/includes/class-jne-woocommerce-webhook-logger.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce-webhook-logger.php)
-
tags/1.4.1/includes/class-jne-woocommerce-webhook.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce-webhook.php)
-
tags/1.4.1/includes/class-jne-woocommerce.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce.php)
-
tags/1.4.1/index.php (copied) (copied from jne-shipping-official/trunk/index.php)
-
tags/1.4.1/jne-shipping-official.php (copied) (copied from jne-shipping-official/trunk/jne-shipping-official.php) (1 diff)
-
tags/1.4.1/languages (copied) (copied from jne-shipping-official/trunk/languages)
-
tags/1.4.1/public (copied) (copied from jne-shipping-official/trunk/public)
-
tags/1.4.1/public/class-jne-woocommerce-public.php (copied) (copied from jne-shipping-official/trunk/public/class-jne-woocommerce-public.php)
-
tags/1.4.1/public/includes/jne-woocommerce-public-cod.php (copied) (copied from jne-shipping-official/trunk/public/includes/jne-woocommerce-public-cod.php)
-
tags/1.4.1/public/includes/jne-woocommerce-public-insurance.php (copied) (copied from jne-shipping-official/trunk/public/includes/jne-woocommerce-public-insurance.php)
-
tags/1.4.1/public/includes/jne-woocommerce-public-shipping-cost-adjustment.php (copied) (copied from jne-shipping-official/trunk/public/includes/jne-woocommerce-public-shipping-cost-adjustment.php)
-
tags/1.4.1/readme.txt (copied) (copied from jne-shipping-official/trunk/readme.txt) (2 diffs)
-
tags/1.4.1/uninstall.php (copied) (copied from jne-shipping-official/trunk/uninstall.php)
-
tags/1.4.1/vendor (copied) (copied from jne-shipping-official/trunk/vendor)
-
trunk/admin/class-jne-woocommerce-admin.php (modified) (1 diff)
-
trunk/admin/includes/class-jne-admin-order-helper.php (modified) (1 diff)
-
trunk/admin/includes/class-jne-admin-shipping-method.php (modified) (3 diffs)
-
trunk/admin/includes/class-jne-weight-helper.php (added)
-
trunk/composer.json (modified) (1 diff)
-
trunk/jne-shipping-official.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jne-shipping-official/tags/1.4.1/admin/class-jne-woocommerce-admin.php
r3411298 r3426854 111 111 private function load_dependencies() 112 112 { 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'; 113 115 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-order-search-list.php'; 114 116 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 234 234 /** 235 235 * 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 237 240 */ 238 241 public function getOrderTotalWeight(): int 239 242 { 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); 253 253 } 254 254 -
jne-shipping-official/tags/1.4.1/admin/includes/class-jne-admin-shipping-method.php
r3426041 r3426854 8 8 if (!class_exists('Jneshof_Admin_Shipping_Cost_Adjustment')) { 9 9 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) 13 if (!class_exists('Jneshof_Weight_Helper')) { 14 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php'; 10 15 } 11 16 … … 279 284 280 285 /** 281 * Convert weight to kilograms based on WooCommerce weight unit setting282 *283 * @param float $weight Weight value284 * @param string $from_unit Source unit (kg, g, lbs, oz)285 * @return float Weight in kilograms286 */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 kilograms294 return floatval($weight);295 296 case 'g':297 // Convert grams to kilograms: 1 g = 0.001 kg298 return floatval($weight) * 0.001;299 300 case 'lbs':301 // Convert pounds to kilograms: 1 lb = 0.453592 kg302 return floatval($weight) * 0.453592;303 304 case 'oz':305 // Convert ounces to kilograms: 1 oz = 0.0283495 kg306 return floatval($weight) * 0.0283495;307 308 default:309 // Default to kilograms if unit is unknown310 return floatval($weight);311 }312 }313 314 /**315 * Get WooCommerce weight unit setting316 *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 lowercase325 return strtolower($weight_unit);326 }327 328 /**329 286 * Calculate total weight of package 287 * Uses centralized weight helper for consistency 330 288 * 331 289 * @param array $package Package data … … 334 292 private function get_weight($package) 335 293 { 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 2 2 "name": "jne-shipping/jne-shipping-official", 3 3 "description": "WordPress plugin integrated with WooCommerce for JNE shipping services", 4 "version": "1.4. 0",4 "version": "1.4.1", 5 5 "type": "wordpress-plugin", 6 6 "license": "GPL-2.0+", -
jne-shipping-official/tags/1.4.1/jne-shipping-official.php
r3426041 r3426854 20 20 * Plugin Name: JNE Shipping Official 21 21 * Description: WordPress plugin integrated with WooCommerce for JNE shipping services 22 * Version: 1.4. 022 * Version: 1.4.1 23 23 * Author: PT. Tiki Jalur Nugraha Ekakurir 24 24 * Author URI: https://jne.co.id/ -
jne-shipping-official/tags/1.4.1/readme.txt
r3426041 r3426854 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1.4. 08 Stable tag: 1.4.1 9 9 License: GPL-2.0+ 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 90 90 91 91 == 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 92 100 93 101 = 1.4.0 = -
jne-shipping-official/trunk/admin/class-jne-woocommerce-admin.php
r3411298 r3426854 111 111 private function load_dependencies() 112 112 { 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'; 113 115 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-admin-order-search-list.php'; 114 116 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 234 234 /** 235 235 * 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 237 240 */ 238 241 public function getOrderTotalWeight(): int 239 242 { 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); 253 253 } 254 254 -
jne-shipping-official/trunk/admin/includes/class-jne-admin-shipping-method.php
r3426041 r3426854 8 8 if (!class_exists('Jneshof_Admin_Shipping_Cost_Adjustment')) { 9 9 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) 13 if (!class_exists('Jneshof_Weight_Helper')) { 14 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/includes/class-jne-weight-helper.php'; 10 15 } 11 16 … … 279 284 280 285 /** 281 * Convert weight to kilograms based on WooCommerce weight unit setting282 *283 * @param float $weight Weight value284 * @param string $from_unit Source unit (kg, g, lbs, oz)285 * @return float Weight in kilograms286 */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 kilograms294 return floatval($weight);295 296 case 'g':297 // Convert grams to kilograms: 1 g = 0.001 kg298 return floatval($weight) * 0.001;299 300 case 'lbs':301 // Convert pounds to kilograms: 1 lb = 0.453592 kg302 return floatval($weight) * 0.453592;303 304 case 'oz':305 // Convert ounces to kilograms: 1 oz = 0.0283495 kg306 return floatval($weight) * 0.0283495;307 308 default:309 // Default to kilograms if unit is unknown310 return floatval($weight);311 }312 }313 314 /**315 * Get WooCommerce weight unit setting316 *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 lowercase325 return strtolower($weight_unit);326 }327 328 /**329 286 * Calculate total weight of package 287 * Uses centralized weight helper for consistency 330 288 * 331 289 * @param array $package Package data … … 334 292 private function get_weight($package) 335 293 { 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 2 2 "name": "jne-shipping/jne-shipping-official", 3 3 "description": "WordPress plugin integrated with WooCommerce for JNE shipping services", 4 "version": "1.4. 0",4 "version": "1.4.1", 5 5 "type": "wordpress-plugin", 6 6 "license": "GPL-2.0+", -
jne-shipping-official/trunk/jne-shipping-official.php
r3426041 r3426854 20 20 * Plugin Name: JNE Shipping Official 21 21 * Description: WordPress plugin integrated with WooCommerce for JNE shipping services 22 * Version: 1.4. 022 * Version: 1.4.1 23 23 * Author: PT. Tiki Jalur Nugraha Ekakurir 24 24 * Author URI: https://jne.co.id/ -
jne-shipping-official/trunk/readme.txt
r3426041 r3426854 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1.4. 08 Stable tag: 1.4.1 9 9 License: GPL-2.0+ 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 90 90 91 91 == 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 92 100 93 101 = 1.4.0 =
Note: See TracChangeset
for help on using the changeset viewer.