Changeset 3442292
- Timestamp:
- 01/19/2026 08:19:22 AM (5 weeks ago)
- Location:
- jne-shipping-official
- Files:
-
- 10 edited
- 35 copied
-
tags/1.5.0 (copied) (copied from jne-shipping-official/trunk)
-
tags/1.5.0/LICENSE.txt (copied) (copied from jne-shipping-official/trunk/LICENSE.txt)
-
tags/1.5.0/admin (copied) (copied from jne-shipping-official/trunk/admin)
-
tags/1.5.0/admin/class-jne-woocommerce-admin.php (copied) (copied from jne-shipping-official/trunk/admin/class-jne-woocommerce-admin.php) (1 diff)
-
tags/1.5.0/admin/includes/class-jne-admin-dashboard.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-dashboard.php)
-
tags/1.5.0/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.5.0/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.5.0/admin/includes/class-jne-admin-order-helper.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-order-helper.php) (2 diffs)
-
tags/1.5.0/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.5.0/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.5.0/admin/includes/class-jne-admin-shipping-method.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-admin-shipping-method.php)
-
tags/1.5.0/admin/includes/class-jne-admin-store-helper.php (modified) (1 diff)
-
tags/1.5.0/admin/includes/class-jne-weight-helper.php (copied) (copied from jne-shipping-official/trunk/admin/includes/class-jne-weight-helper.php)
-
tags/1.5.0/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.5.0/admin/partials/jne-woocommerce-admin-setting-display.php (modified) (3 diffs)
-
tags/1.5.0/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.5.0/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.5.0/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.5.0/assets (copied) (copied from jne-shipping-official/trunk/assets)
-
tags/1.5.0/composer.json (copied) (copied from jne-shipping-official/trunk/composer.json) (1 diff)
-
tags/1.5.0/composer.lock (copied) (copied from jne-shipping-official/trunk/composer.lock)
-
tags/1.5.0/includes (copied) (copied from jne-shipping-official/trunk/includes)
-
tags/1.5.0/includes/class-jne-woocommerce-api.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce-api.php)
-
tags/1.5.0/includes/class-jne-woocommerce-webhook-logger.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce-webhook-logger.php)
-
tags/1.5.0/includes/class-jne-woocommerce-webhook.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce-webhook.php)
-
tags/1.5.0/includes/class-jne-woocommerce.php (copied) (copied from jne-shipping-official/trunk/includes/class-jne-woocommerce.php)
-
tags/1.5.0/index.php (copied) (copied from jne-shipping-official/trunk/index.php)
-
tags/1.5.0/jne-shipping-official.php (copied) (copied from jne-shipping-official/trunk/jne-shipping-official.php) (2 diffs)
-
tags/1.5.0/languages (copied) (copied from jne-shipping-official/trunk/languages)
-
tags/1.5.0/public (copied) (copied from jne-shipping-official/trunk/public)
-
tags/1.5.0/public/class-jne-woocommerce-public.php (copied) (copied from jne-shipping-official/trunk/public/class-jne-woocommerce-public.php)
-
tags/1.5.0/public/includes/jne-woocommerce-public-cod.php (copied) (copied from jne-shipping-official/trunk/public/includes/jne-woocommerce-public-cod.php)
-
tags/1.5.0/public/includes/jne-woocommerce-public-insurance.php (copied) (copied from jne-shipping-official/trunk/public/includes/jne-woocommerce-public-insurance.php) (2 diffs)
-
tags/1.5.0/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.5.0/readme.txt (copied) (copied from jne-shipping-official/trunk/readme.txt) (3 diffs)
-
tags/1.5.0/uninstall.php (copied) (copied from jne-shipping-official/trunk/uninstall.php)
-
tags/1.5.0/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) (2 diffs)
-
trunk/admin/includes/class-jne-admin-store-helper.php (modified) (1 diff)
-
trunk/admin/partials/jne-woocommerce-admin-setting-display.php (modified) (3 diffs)
-
trunk/composer.json (modified) (1 diff)
-
trunk/jne-shipping-official.php (modified) (2 diffs)
-
trunk/public/includes/jne-woocommerce-public-insurance.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jne-shipping-official/tags/1.5.0/admin/class-jne-woocommerce-admin.php
r3426854 r3442292 598 598 'origin_phone' => sanitize_text_field($data['origin_phone'] ?? ''), 599 599 'shipping_insurance_enabled' => isset($data['shipping_insurance_enabled']) ? 1 : 0, 600 'shipping_insurance_charged_to' => isset($data['shipping_insurance_charged_to']) && in_array($data['shipping_insurance_charged_to'], ['buyer', 'seller']) ? $data['shipping_insurance_charged_to'] : 'buyer', 600 601 'mask_awb_name' => isset($data['mask_awb_name']) ? 1 : 0, 601 602 'mask_awb_phone' => 1, -
jne-shipping-official/tags/1.5.0/admin/includes/class-jne-admin-order-helper.php
r3426854 r3442292 15 15 const JNESHOF_ORDER_META_KEY_PICKUP_DATE = 'jneshof_shipping_pickup_date'; 16 16 const JNESHOF_ORDER_META_KEY_IS_LABEL_PRINTED = 'jneshof_is_label_printed'; 17 const JNESHOF_ORDER_META_KEY_INSURANCE_COST = 'jneshof_shipping_insurance_cost'; 18 const JNESHOF_ORDER_META_KEY_INSURANCE_CHARGED_TO = 'jneshof_shipping_insurance_charged_to'; 17 19 18 20 /** @var WC_Order|null */ … … 159 161 /** 160 162 * Get shipping insurance cost. 163 * Checks order meta first (for seller-charged insurance), then fees (for buyer-charged insurance). 164 * If not found, calculates based on order subtotal if insurance is enabled. 161 165 * @return float|null 162 166 */ 163 167 public function getShippingInsuranceCost(): ?float 164 168 { 169 // First check order meta (for seller-charged insurance) 170 $insurance_cost = $this->order->get_meta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST); 171 if ($insurance_cost !== '' && $insurance_cost !== null && $insurance_cost > 0) { 172 return (float) $insurance_cost; 173 } 174 175 // Fallback to fees (for buyer-charged insurance - backward compatibility) 165 176 $fees = $this->order->get_fees(); 166 177 foreach($fees as $fee) { 167 178 if($fee->get_name() === 'Shipping Insurance') { 168 return $fee->get_amount(); 179 $insurance_cost = $fee->get_amount(); 180 // Save to meta for consistency 181 if ($insurance_cost > 0) { 182 $this->updateOrderMeta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST, $insurance_cost); 183 } 184 return $insurance_cost; 169 185 } 170 186 } 187 188 // Last resort: Calculate if insurance is enabled and order uses JNE shipping 189 $store_settings = get_option(JNESHOF_OPTION_STORE_SETTINGS, []); 190 $insurance_enabled = $store_settings['shipping_insurance_enabled'] ?? false; 191 192 if ($insurance_enabled && $this->isJNEShippingMethod()) { 193 $goods_value = $this->order->get_subtotal(); 194 $insurance_cost = ($goods_value * 0.002) + 5000; 195 196 // Save calculated cost to meta 197 $this->updateOrderMeta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST, $insurance_cost); 198 199 return $insurance_cost; 200 } 201 171 202 return null; 203 } 204 205 /** 206 * Save shipping insurance cost to order meta. 207 * @param float $insurance_cost 208 * @return void 209 */ 210 public function saveShippingInsuranceCost(float $insurance_cost): void 211 { 212 $this->updateOrderMeta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST, $insurance_cost); 172 213 } 173 214 -
jne-shipping-official/tags/1.5.0/admin/includes/class-jne-admin-store-helper.php
r3387194 r3442292 96 96 { 97 97 return $this->store_settings['shipping_insurance_enabled'] ?? false; 98 } 99 100 /** 101 * Get shipping insurance charged to (buyer or seller) 102 * @return string 'buyer' or 'seller' (default: 'buyer') 103 */ 104 public function getShippingInsuranceChargedTo() 105 { 106 $charged_to = $this->store_settings['shipping_insurance_charged_to'] ?? 'buyer'; 107 return in_array($charged_to, ['buyer', 'seller']) ? $charged_to : 'buyer'; 98 108 } 99 109 -
jne-shipping-official/tags/1.5.0/admin/partials/jne-woocommerce-admin-setting-display.php
r3387194 r3442292 17 17 if (isset($_POST['shipping_insurance_enabled']) && sanitize_text_field(wp_unslash($_POST['shipping_insurance_enabled']))) { 18 18 $sanitized_data['shipping_insurance_enabled'] = 1; 19 } 20 // Handle shipping insurance charged to option 21 if (isset($_POST['shipping_insurance_charged_to'])) { 22 $charged_to = sanitize_text_field(wp_unslash($_POST['shipping_insurance_charged_to'])); 23 $sanitized_data['shipping_insurance_charged_to'] = in_array($charged_to, ['buyer', 'seller']) ? $charged_to : 'buyer'; 19 24 } 20 25 if (isset($_POST['mask_awb_name']) && sanitize_text_field(wp_unslash($_POST['mask_awb_name']))) { … … 36 41 $store_settings = Jneshof_Woocommerce_Configs::get_store_settings(); 37 42 $shipping_insurance_enabled = isset($store_settings['shipping_insurance_enabled']) ? (int) $store_settings['shipping_insurance_enabled'] : 0; 43 $shipping_insurance_charged_to = isset($store_settings['shipping_insurance_charged_to']) ? $store_settings['shipping_insurance_charged_to'] : 'buyer'; 38 44 $origin_code = $store_settings['origin_code'] ?? ''; 39 45 $origin_name = $store_settings['origin_name'] ?? ''; … … 113 119 </label> 114 120 </div> 121 122 <!-- Insurance Charged To Option --> 123 <?php if ($shipping_insurance_enabled): ?> 124 <div class="mt-3 ms-4"> 125 <label class="form-label fw-medium text-dark small" for="shipping_insurance_charged_to"> 126 <?php esc_html_e('Biaya Asuransi Dibebankan ke', 'jne-shipping-official'); ?> 127 </label> 128 <div class="form-check"> 129 <input class="form-check-input" type="radio" id="shipping_insurance_charged_to_seller" 130 name="shipping_insurance_charged_to" value="seller" <?php checked($shipping_insurance_charged_to, 'seller'); ?> /> 131 <label class="form-check-label" for="shipping_insurance_charged_to_seller"> 132 <?php esc_html_e('Penjual', 'jne-shipping-official'); ?> 133 </label> 134 </div> 135 <div class="form-check"> 136 <input class="form-check-input" type="radio" id="shipping_insurance_charged_to_buyer" 137 name="shipping_insurance_charged_to" value="buyer" <?php checked($shipping_insurance_charged_to, 'buyer'); ?> /> 138 <label class="form-check-label" for="shipping_insurance_charged_to_buyer"> 139 <?php esc_html_e('Pembeli (Default)', 'jne-shipping-official'); ?> 140 </label> 141 </div> 142 <small class="form-text text-muted d-block mt-2"> 143 <?php esc_html_e('Pilih siapa yang akan membayar biaya asuransi. Jika dipilih Penjual, biaya tidak akan ditambahkan ke total pembayaran pelanggan.', 'jne-shipping-official'); ?> 144 </small> 145 </div> 146 <?php endif; ?> 115 147 </div> 116 148 -
jne-shipping-official/tags/1.5.0/composer.json
r3439605 r3442292 2 2 "name": "jne-shipping/jne-shipping-official", 3 3 "description": "WordPress plugin integrated with WooCommerce for JNE shipping services", 4 "version": "1. 4.2",4 "version": "1.5.0", 5 5 "type": "wordpress-plugin", 6 6 "license": "GPL-2.0+", -
jne-shipping-official/tags/1.5.0/jne-shipping-official.php
r3439605 r3442292 20 20 * Plugin Name: JNE Shipping Official 21 21 * Description: WordPress plugin integrated with WooCommerce for JNE shipping services 22 * Version: 1. 4.222 * Version: 1.5.0 23 23 * Author: PT. Tiki Jalur Nugraha Ekakurir 24 24 * Author URI: https://jne.co.id/ … … 48 48 * Rename this for your plugin and update it as you release new versions. 49 49 */ 50 define('JNESHOF_PLUGIN_VERSION', '1. 4.2');50 define('JNESHOF_PLUGIN_VERSION', '1.5.0'); 51 51 52 52 /** -
jne-shipping-official/tags/1.5.0/public/includes/jne-woocommerce-public-insurance.php
r3391256 r3442292 23 23 if ($all_required_checklist_checked) { 24 24 add_action('woocommerce_cart_calculate_fees', [$this, 'calculate_shipping_insurance']); 25 add_action('woocommerce_checkout_create_order', [$this, 'save_insurance_cost_to_order'], 10, 2); 25 26 } 26 27 } … … 58 59 } 59 60 60 $insurance_enabled = get_option(JNESHOF_OPTION_STORE_SETTINGS, [])['shipping_insurance_enabled'] ?? false; 61 $store_settings = get_option(JNESHOF_OPTION_STORE_SETTINGS, []); 62 $insurance_enabled = $store_settings['shipping_insurance_enabled'] ?? false; 63 $insurance_charged_to = $store_settings['shipping_insurance_charged_to'] ?? 'buyer'; 64 65 // Clear session if insurance is disabled or shipping method is not JNE 66 if (!$insurance_enabled || !$is_shipping_method_jne) { 67 if (WC()->session) { 68 WC()->session->__unset('jneshof_insurance_cost'); 69 } 70 return; 71 } 72 61 73 if ($insurance_enabled && $is_shipping_method_jne) { 62 74 $goods_value = $cart->get_subtotal(); 63 75 $insurance_fee = ($goods_value * 0.002) + 5000; 64 $cart->add_fee('Shipping Insurance', $insurance_fee, true, ''); 76 77 // Only add as cart fee if charged to buyer 78 if ($insurance_charged_to === 'buyer') { 79 $cart->add_fee('Shipping Insurance', $insurance_fee, true, ''); 80 // Clear session if switching from seller to buyer 81 if (WC()->session) { 82 WC()->session->__unset('jneshof_insurance_cost'); 83 } 84 } else { 85 // Store insurance cost in session for later saving to order meta 86 if (WC()->session) { 87 WC()->session->set('jneshof_insurance_cost', $insurance_fee); 88 } 89 } 90 } 91 } 92 93 /** 94 * Save insurance cost to order meta (for both buyer and seller charged) 95 * This ensures insurance cost is always available for tracking and AWB label 96 * 97 * @param WC_Order $order 98 * @param array $data 99 */ 100 public function save_insurance_cost_to_order($order, $data) 101 { 102 $store_settings = get_option(JNESHOF_OPTION_STORE_SETTINGS, []); 103 $insurance_enabled = $store_settings['shipping_insurance_enabled'] ?? false; 104 $insurance_charged_to = $store_settings['shipping_insurance_charged_to'] ?? 'buyer'; 105 106 if (!$insurance_enabled) { 107 return; 108 } 109 110 // Check if order uses JNE shipping 111 $is_jne_shipping = false; 112 $shipping_methods = $order->get_shipping_methods(); 113 foreach ($shipping_methods as $shipping_method) { 114 if (method_exists($shipping_method, 'get_method_id') && 115 $shipping_method->get_method_id() === self::JNESHOF_SHIPPING_METHOD_ID) { 116 $is_jne_shipping = true; 117 break; 118 } 119 } 120 121 if (!$is_jne_shipping) { 122 return; 123 } 124 125 $insurance_cost = null; 126 127 // Get insurance cost based on who is charged 128 if ($insurance_charged_to === 'buyer') { 129 // Get from order fees (already added to order as cart fee) 130 $fees = $order->get_fees(); 131 foreach($fees as $fee) { 132 if($fee->get_name() === 'Shipping Insurance') { 133 $insurance_cost = $fee->get_amount(); 134 break; 135 } 136 } 137 } else { 138 // Get from session (seller-charged) 139 if (WC()->session) { 140 $insurance_cost = WC()->session->get('jneshof_insurance_cost'); 141 // Clear session data 142 WC()->session->__unset('jneshof_insurance_cost'); 143 } 144 145 // Fallback: Calculate if not in session 146 if (!$insurance_cost || $insurance_cost <= 0) { 147 $goods_value = $order->get_subtotal(); 148 $insurance_cost = ($goods_value * 0.002) + 5000; 149 } 150 } 151 152 // Save to order meta for tracking and AWB label (for both buyer and seller) 153 if ($insurance_cost && $insurance_cost > 0) { 154 $order->update_meta_data('jneshof_shipping_insurance_cost', $insurance_cost); 155 $order->update_meta_data('jneshof_shipping_insurance_charged_to', $insurance_charged_to); 65 156 } 66 157 } -
jne-shipping-official/tags/1.5.0/readme.txt
r3439605 r3442292 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1. 4.28 Stable tag: 1.5.0 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.5.0 = 94 * Added: Insurance cost charge option - Choose whether insurance cost is charged to buyer or seller (default: buyer) 95 * Added: Insurance cost is now always saved to order meta for tracking and AWB label display, regardless of who pays 92 96 93 97 = 1.4.2 = … … 222 226 == Upgrade Notice == 223 227 228 = 1.5.0 = 229 Major feature update: Added insurance cost charge option allowing you to choose whether insurance is charged to buyer or seller. Default is buyer. Insurance cost is now always saved to order meta for proper tracking and AWB label display. Includes automatic fallback calculation to ensure insurance cost is always available. Fixed issue where insurance cost didn't display in AWB label when charged to seller. Recommended for all users. 230 224 231 = 1.4.2 = 225 232 Bug fix update: Fixed critical issue where JNE Actions column, No. Resi column, and bulk actions were not appearing on WooCommerce orders page for users with HPOS disabled or using legacy order screen. Plugin now fully supports both HPOS and legacy CPT order screens. Recommended for all users experiencing missing columns or bulk actions. -
jne-shipping-official/trunk/admin/class-jne-woocommerce-admin.php
r3426854 r3442292 598 598 'origin_phone' => sanitize_text_field($data['origin_phone'] ?? ''), 599 599 'shipping_insurance_enabled' => isset($data['shipping_insurance_enabled']) ? 1 : 0, 600 'shipping_insurance_charged_to' => isset($data['shipping_insurance_charged_to']) && in_array($data['shipping_insurance_charged_to'], ['buyer', 'seller']) ? $data['shipping_insurance_charged_to'] : 'buyer', 600 601 'mask_awb_name' => isset($data['mask_awb_name']) ? 1 : 0, 601 602 'mask_awb_phone' => 1, -
jne-shipping-official/trunk/admin/includes/class-jne-admin-order-helper.php
r3426854 r3442292 15 15 const JNESHOF_ORDER_META_KEY_PICKUP_DATE = 'jneshof_shipping_pickup_date'; 16 16 const JNESHOF_ORDER_META_KEY_IS_LABEL_PRINTED = 'jneshof_is_label_printed'; 17 const JNESHOF_ORDER_META_KEY_INSURANCE_COST = 'jneshof_shipping_insurance_cost'; 18 const JNESHOF_ORDER_META_KEY_INSURANCE_CHARGED_TO = 'jneshof_shipping_insurance_charged_to'; 17 19 18 20 /** @var WC_Order|null */ … … 159 161 /** 160 162 * Get shipping insurance cost. 163 * Checks order meta first (for seller-charged insurance), then fees (for buyer-charged insurance). 164 * If not found, calculates based on order subtotal if insurance is enabled. 161 165 * @return float|null 162 166 */ 163 167 public function getShippingInsuranceCost(): ?float 164 168 { 169 // First check order meta (for seller-charged insurance) 170 $insurance_cost = $this->order->get_meta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST); 171 if ($insurance_cost !== '' && $insurance_cost !== null && $insurance_cost > 0) { 172 return (float) $insurance_cost; 173 } 174 175 // Fallback to fees (for buyer-charged insurance - backward compatibility) 165 176 $fees = $this->order->get_fees(); 166 177 foreach($fees as $fee) { 167 178 if($fee->get_name() === 'Shipping Insurance') { 168 return $fee->get_amount(); 179 $insurance_cost = $fee->get_amount(); 180 // Save to meta for consistency 181 if ($insurance_cost > 0) { 182 $this->updateOrderMeta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST, $insurance_cost); 183 } 184 return $insurance_cost; 169 185 } 170 186 } 187 188 // Last resort: Calculate if insurance is enabled and order uses JNE shipping 189 $store_settings = get_option(JNESHOF_OPTION_STORE_SETTINGS, []); 190 $insurance_enabled = $store_settings['shipping_insurance_enabled'] ?? false; 191 192 if ($insurance_enabled && $this->isJNEShippingMethod()) { 193 $goods_value = $this->order->get_subtotal(); 194 $insurance_cost = ($goods_value * 0.002) + 5000; 195 196 // Save calculated cost to meta 197 $this->updateOrderMeta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST, $insurance_cost); 198 199 return $insurance_cost; 200 } 201 171 202 return null; 203 } 204 205 /** 206 * Save shipping insurance cost to order meta. 207 * @param float $insurance_cost 208 * @return void 209 */ 210 public function saveShippingInsuranceCost(float $insurance_cost): void 211 { 212 $this->updateOrderMeta(self::JNESHOF_ORDER_META_KEY_INSURANCE_COST, $insurance_cost); 172 213 } 173 214 -
jne-shipping-official/trunk/admin/includes/class-jne-admin-store-helper.php
r3387194 r3442292 96 96 { 97 97 return $this->store_settings['shipping_insurance_enabled'] ?? false; 98 } 99 100 /** 101 * Get shipping insurance charged to (buyer or seller) 102 * @return string 'buyer' or 'seller' (default: 'buyer') 103 */ 104 public function getShippingInsuranceChargedTo() 105 { 106 $charged_to = $this->store_settings['shipping_insurance_charged_to'] ?? 'buyer'; 107 return in_array($charged_to, ['buyer', 'seller']) ? $charged_to : 'buyer'; 98 108 } 99 109 -
jne-shipping-official/trunk/admin/partials/jne-woocommerce-admin-setting-display.php
r3387194 r3442292 17 17 if (isset($_POST['shipping_insurance_enabled']) && sanitize_text_field(wp_unslash($_POST['shipping_insurance_enabled']))) { 18 18 $sanitized_data['shipping_insurance_enabled'] = 1; 19 } 20 // Handle shipping insurance charged to option 21 if (isset($_POST['shipping_insurance_charged_to'])) { 22 $charged_to = sanitize_text_field(wp_unslash($_POST['shipping_insurance_charged_to'])); 23 $sanitized_data['shipping_insurance_charged_to'] = in_array($charged_to, ['buyer', 'seller']) ? $charged_to : 'buyer'; 19 24 } 20 25 if (isset($_POST['mask_awb_name']) && sanitize_text_field(wp_unslash($_POST['mask_awb_name']))) { … … 36 41 $store_settings = Jneshof_Woocommerce_Configs::get_store_settings(); 37 42 $shipping_insurance_enabled = isset($store_settings['shipping_insurance_enabled']) ? (int) $store_settings['shipping_insurance_enabled'] : 0; 43 $shipping_insurance_charged_to = isset($store_settings['shipping_insurance_charged_to']) ? $store_settings['shipping_insurance_charged_to'] : 'buyer'; 38 44 $origin_code = $store_settings['origin_code'] ?? ''; 39 45 $origin_name = $store_settings['origin_name'] ?? ''; … … 113 119 </label> 114 120 </div> 121 122 <!-- Insurance Charged To Option --> 123 <?php if ($shipping_insurance_enabled): ?> 124 <div class="mt-3 ms-4"> 125 <label class="form-label fw-medium text-dark small" for="shipping_insurance_charged_to"> 126 <?php esc_html_e('Biaya Asuransi Dibebankan ke', 'jne-shipping-official'); ?> 127 </label> 128 <div class="form-check"> 129 <input class="form-check-input" type="radio" id="shipping_insurance_charged_to_seller" 130 name="shipping_insurance_charged_to" value="seller" <?php checked($shipping_insurance_charged_to, 'seller'); ?> /> 131 <label class="form-check-label" for="shipping_insurance_charged_to_seller"> 132 <?php esc_html_e('Penjual', 'jne-shipping-official'); ?> 133 </label> 134 </div> 135 <div class="form-check"> 136 <input class="form-check-input" type="radio" id="shipping_insurance_charged_to_buyer" 137 name="shipping_insurance_charged_to" value="buyer" <?php checked($shipping_insurance_charged_to, 'buyer'); ?> /> 138 <label class="form-check-label" for="shipping_insurance_charged_to_buyer"> 139 <?php esc_html_e('Pembeli (Default)', 'jne-shipping-official'); ?> 140 </label> 141 </div> 142 <small class="form-text text-muted d-block mt-2"> 143 <?php esc_html_e('Pilih siapa yang akan membayar biaya asuransi. Jika dipilih Penjual, biaya tidak akan ditambahkan ke total pembayaran pelanggan.', 'jne-shipping-official'); ?> 144 </small> 145 </div> 146 <?php endif; ?> 115 147 </div> 116 148 -
jne-shipping-official/trunk/composer.json
r3439605 r3442292 2 2 "name": "jne-shipping/jne-shipping-official", 3 3 "description": "WordPress plugin integrated with WooCommerce for JNE shipping services", 4 "version": "1. 4.2",4 "version": "1.5.0", 5 5 "type": "wordpress-plugin", 6 6 "license": "GPL-2.0+", -
jne-shipping-official/trunk/jne-shipping-official.php
r3439605 r3442292 20 20 * Plugin Name: JNE Shipping Official 21 21 * Description: WordPress plugin integrated with WooCommerce for JNE shipping services 22 * Version: 1. 4.222 * Version: 1.5.0 23 23 * Author: PT. Tiki Jalur Nugraha Ekakurir 24 24 * Author URI: https://jne.co.id/ … … 48 48 * Rename this for your plugin and update it as you release new versions. 49 49 */ 50 define('JNESHOF_PLUGIN_VERSION', '1. 4.2');50 define('JNESHOF_PLUGIN_VERSION', '1.5.0'); 51 51 52 52 /** -
jne-shipping-official/trunk/public/includes/jne-woocommerce-public-insurance.php
r3391256 r3442292 23 23 if ($all_required_checklist_checked) { 24 24 add_action('woocommerce_cart_calculate_fees', [$this, 'calculate_shipping_insurance']); 25 add_action('woocommerce_checkout_create_order', [$this, 'save_insurance_cost_to_order'], 10, 2); 25 26 } 26 27 } … … 58 59 } 59 60 60 $insurance_enabled = get_option(JNESHOF_OPTION_STORE_SETTINGS, [])['shipping_insurance_enabled'] ?? false; 61 $store_settings = get_option(JNESHOF_OPTION_STORE_SETTINGS, []); 62 $insurance_enabled = $store_settings['shipping_insurance_enabled'] ?? false; 63 $insurance_charged_to = $store_settings['shipping_insurance_charged_to'] ?? 'buyer'; 64 65 // Clear session if insurance is disabled or shipping method is not JNE 66 if (!$insurance_enabled || !$is_shipping_method_jne) { 67 if (WC()->session) { 68 WC()->session->__unset('jneshof_insurance_cost'); 69 } 70 return; 71 } 72 61 73 if ($insurance_enabled && $is_shipping_method_jne) { 62 74 $goods_value = $cart->get_subtotal(); 63 75 $insurance_fee = ($goods_value * 0.002) + 5000; 64 $cart->add_fee('Shipping Insurance', $insurance_fee, true, ''); 76 77 // Only add as cart fee if charged to buyer 78 if ($insurance_charged_to === 'buyer') { 79 $cart->add_fee('Shipping Insurance', $insurance_fee, true, ''); 80 // Clear session if switching from seller to buyer 81 if (WC()->session) { 82 WC()->session->__unset('jneshof_insurance_cost'); 83 } 84 } else { 85 // Store insurance cost in session for later saving to order meta 86 if (WC()->session) { 87 WC()->session->set('jneshof_insurance_cost', $insurance_fee); 88 } 89 } 90 } 91 } 92 93 /** 94 * Save insurance cost to order meta (for both buyer and seller charged) 95 * This ensures insurance cost is always available for tracking and AWB label 96 * 97 * @param WC_Order $order 98 * @param array $data 99 */ 100 public function save_insurance_cost_to_order($order, $data) 101 { 102 $store_settings = get_option(JNESHOF_OPTION_STORE_SETTINGS, []); 103 $insurance_enabled = $store_settings['shipping_insurance_enabled'] ?? false; 104 $insurance_charged_to = $store_settings['shipping_insurance_charged_to'] ?? 'buyer'; 105 106 if (!$insurance_enabled) { 107 return; 108 } 109 110 // Check if order uses JNE shipping 111 $is_jne_shipping = false; 112 $shipping_methods = $order->get_shipping_methods(); 113 foreach ($shipping_methods as $shipping_method) { 114 if (method_exists($shipping_method, 'get_method_id') && 115 $shipping_method->get_method_id() === self::JNESHOF_SHIPPING_METHOD_ID) { 116 $is_jne_shipping = true; 117 break; 118 } 119 } 120 121 if (!$is_jne_shipping) { 122 return; 123 } 124 125 $insurance_cost = null; 126 127 // Get insurance cost based on who is charged 128 if ($insurance_charged_to === 'buyer') { 129 // Get from order fees (already added to order as cart fee) 130 $fees = $order->get_fees(); 131 foreach($fees as $fee) { 132 if($fee->get_name() === 'Shipping Insurance') { 133 $insurance_cost = $fee->get_amount(); 134 break; 135 } 136 } 137 } else { 138 // Get from session (seller-charged) 139 if (WC()->session) { 140 $insurance_cost = WC()->session->get('jneshof_insurance_cost'); 141 // Clear session data 142 WC()->session->__unset('jneshof_insurance_cost'); 143 } 144 145 // Fallback: Calculate if not in session 146 if (!$insurance_cost || $insurance_cost <= 0) { 147 $goods_value = $order->get_subtotal(); 148 $insurance_cost = ($goods_value * 0.002) + 5000; 149 } 150 } 151 152 // Save to order meta for tracking and AWB label (for both buyer and seller) 153 if ($insurance_cost && $insurance_cost > 0) { 154 $order->update_meta_data('jneshof_shipping_insurance_cost', $insurance_cost); 155 $order->update_meta_data('jneshof_shipping_insurance_charged_to', $insurance_charged_to); 65 156 } 66 157 } -
jne-shipping-official/trunk/readme.txt
r3439605 r3442292 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1. 4.28 Stable tag: 1.5.0 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.5.0 = 94 * Added: Insurance cost charge option - Choose whether insurance cost is charged to buyer or seller (default: buyer) 95 * Added: Insurance cost is now always saved to order meta for tracking and AWB label display, regardless of who pays 92 96 93 97 = 1.4.2 = … … 222 226 == Upgrade Notice == 223 227 228 = 1.5.0 = 229 Major feature update: Added insurance cost charge option allowing you to choose whether insurance is charged to buyer or seller. Default is buyer. Insurance cost is now always saved to order meta for proper tracking and AWB label display. Includes automatic fallback calculation to ensure insurance cost is always available. Fixed issue where insurance cost didn't display in AWB label when charged to seller. Recommended for all users. 230 224 231 = 1.4.2 = 225 232 Bug fix update: Fixed critical issue where JNE Actions column, No. Resi column, and bulk actions were not appearing on WooCommerce orders page for users with HPOS disabled or using legacy order screen. Plugin now fully supports both HPOS and legacy CPT order screens. Recommended for all users experiencing missing columns or bulk actions.
Note: See TracChangeset
for help on using the changeset viewer.