Plugin Directory

Changeset 3416278


Ignore:
Timestamp:
12/10/2025 10:18:10 AM (2 months ago)
Author:
jneshipping
Message:

Update to 1.3.0

Location:
jne-shipping-official/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • jne-shipping-official/trunk/admin/includes/class-jne-admin-shipping-cost-adjustment.php

    r3415143 r3416278  
    215215      }
    216216
    217       // All checks passed, add to applicable
     217      // All checks passed, calculate specificity score
     218      $specificity_score = 0;
     219     
     220      // District match = most specific (4 points)
     221      if (!empty($adjustment['districts']) && is_array($adjustment['districts'])) {
     222        $cities_count = !empty($adjustment['cities']) ? count($adjustment['cities']) : 0;
     223        if ($cities_count === 1 && in_array($district_name, $adjustment['districts'])) {
     224          $specificity_score += 4;
     225        }
     226      }
     227     
     228      // City match = specific (3 points)
     229      if (!empty($adjustment['cities']) && is_array($adjustment['cities'])) {
     230        $provinces_count = !empty($adjustment['provinces']) ? count(array_filter($adjustment['provinces'], function($p) {
     231          return $p !== 'all';
     232        })) : 0;
     233        if ($provinces_count === 1 && in_array($city_name, $adjustment['cities'])) {
     234          $specificity_score += 3;
     235        }
     236      }
     237     
     238      // Province match = moderate (2 points)
     239      if (!empty($adjustment['provinces']) && is_array($adjustment['provinces'])) {
     240        if (!in_array('all', $adjustment['provinces'])) {
     241          $province_match = false;
     242          foreach ($adjustment['provinces'] as $province) {
     243            if (is_array($province) && isset($province['name']) && $province['name'] === $province_name) {
     244              $province_match = true;
     245              break;
     246            } elseif (is_string($province) && $province === $province_name) {
     247              $province_match = true;
     248              break;
     249            }
     250          }
     251          if ($province_match) {
     252            $specificity_score += 2;
     253          }
     254        }
     255      }
     256     
     257      // Service match (not "all") = less specific (1 point)
     258      if (!empty($adjustment['services']) && is_array($adjustment['services'])) {
     259        if (!in_array('all', $adjustment['services']) && in_array($service_code, $adjustment['services'])) {
     260          $specificity_score += 1;
     261        }
     262      }
     263     
     264      // Add adjustment with specificity score
     265      $adjustment['_specificity_score'] = $specificity_score;
    218266      $applicable[] = $adjustment;
    219267    }
     268
     269    // Sort by specificity score (highest first), then by created_at (oldest first for tie-breaking)
     270    usort($applicable, function($a, $b) {
     271      $score_a = $a['_specificity_score'] ?? 0;
     272      $score_b = $b['_specificity_score'] ?? 0;
     273     
     274      if ($score_a !== $score_b) {
     275        return $score_b <=> $score_a; // Descending order
     276      }
     277     
     278      // If same specificity, use creation date (older = higher priority)
     279      $created_a = $a['created_at'] ?? '';
     280      $created_b = $b['created_at'] ?? '';
     281      return strcmp($created_a, $created_b);
     282    });
    220283
    221284    return $applicable;
  • jne-shipping-official/trunk/admin/partials/jne-woocommerce-admin-shipping-cost-adjustments-display.php

    r3411310 r3416278  
    224224  <?php else: ?>
    225225    <!-- List View -->
     226    <!-- Priority Rules Info Box -->
     227    <div class="notice notice-info" style="margin: 20px 0; padding: 0; border-left-color: #2271b1; background: #fff;">
     228      <div style="padding: 12px 15px; cursor: pointer;" id="priority-info-toggle" onclick="jQuery('#priority-info-content').slideToggle();">
     229        <div style="display: flex; align-items: center; justify-content: space-between;">
     230          <div style="display: flex; align-items: center; gap: 10px;">
     231            <span class="dashicons dashicons-info" style="color: #2271b1; font-size: 18px;"></span>
     232            <strong style="color: #1d2327; font-size: 13px;">
     233              <?php esc_html_e('How Rules Priority Works', 'jne-shipping-official'); ?>
     234            </strong>
     235          </div>
     236          <span class="dashicons dashicons-arrow-down-alt2" id="priority-info-arrow" style="color: #2271b1; transition: transform 0.3s;"></span>
     237        </div>
     238      </div>
     239      <div id="priority-info-content" style="display: none; padding: 0 15px 15px 15px; border-top: 1px solid #c3c4c7;">
     240        <p style="margin: 12px 0; color: #50575e; line-height: 1.6; font-size: 13px;">
     241          <?php esc_html_e('When multiple rules match a shipping request, the system automatically selects the most specific rule based on priority levels:', 'jne-shipping-official'); ?>
     242        </p>
     243        <div style="background: #f0f6fc; border: 1px solid #c3c4c7; border-radius: 4px; padding: 12px; margin-top: 10px;">
     244          <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; font-size: 13px;">
     245            <div style="display: flex; align-items: center; gap: 10px; padding: 6px 0;">
     246              <span style="display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: #2271b1; color: white; border-radius: 50%; font-weight: 600; font-size: 12px; flex-shrink: 0;">1</span>
     247              <div>
     248                <strong style="color: #1d2327; display: block;"><?php esc_html_e('District Match', 'jne-shipping-official'); ?></strong>
     249                <small style="color: #646970;"><?php esc_html_e('Highest Priority', 'jne-shipping-official'); ?></small>
     250              </div>
     251            </div>
     252            <div style="display: flex; align-items: center; gap: 10px; padding: 6px 0;">
     253              <span style="display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: #2271b1; color: white; border-radius: 50%; font-weight: 600; font-size: 12px; flex-shrink: 0;">2</span>
     254              <div>
     255                <strong style="color: #1d2327; display: block;"><?php esc_html_e('City Match', 'jne-shipping-official'); ?></strong>
     256                <small style="color: #646970;"><?php esc_html_e('High Priority', 'jne-shipping-official'); ?></small>
     257              </div>
     258            </div>
     259            <div style="display: flex; align-items: center; gap: 10px; padding: 6px 0;">
     260              <span style="display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: #2271b1; color: white; border-radius: 50%; font-weight: 600; font-size: 12px; flex-shrink: 0;">3</span>
     261              <div>
     262                <strong style="color: #1d2327; display: block;"><?php esc_html_e('Province Match', 'jne-shipping-official'); ?></strong>
     263                <small style="color: #646970;"><?php esc_html_e('Medium Priority', 'jne-shipping-official'); ?></small>
     264              </div>
     265            </div>
     266            <div style="display: flex; align-items: center; gap: 10px; padding: 6px 0;">
     267              <span style="display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: #2271b1; color: white; border-radius: 50%; font-weight: 600; font-size: 12px; flex-shrink: 0;">4</span>
     268              <div>
     269                <strong style="color: #1d2327; display: block;"><?php esc_html_e('Service Match', 'jne-shipping-official'); ?></strong>
     270                <small style="color: #646970;"><?php esc_html_e('Lowest Priority', 'jne-shipping-official'); ?></small>
     271              </div>
     272            </div>
     273          </div>
     274          <p style="margin: 12px 0 0 0; padding-top: 12px; border-top: 1px solid #c3c4c7; color: #50575e; font-size: 12px; line-height: 1.5;">
     275            <span style="display: inline-block; margin-right: 6px;">💡</span>
     276            <strong><?php esc_html_e('Important:', 'jne-shipping-official'); ?></strong>
     277            <?php esc_html_e('Only one rule is applied per shipping calculation. If multiple rules have the same priority level, the oldest rule (by creation date) takes precedence.', 'jne-shipping-official'); ?>
     278          </p>
     279        </div>
     280      </div>
     281    </div>
     282   
     283    <script>
     284    jQuery(document).ready(function($) {
     285      $('#priority-info-toggle').on('click', function() {
     286        var $arrow = $('#priority-info-arrow');
     287        if ($('#priority-info-content').is(':visible')) {
     288          $arrow.css('transform', 'rotate(0deg)');
     289        } else {
     290          $arrow.css('transform', 'rotate(180deg)');
     291        }
     292      });
     293    });
     294    </script>
     295   
    226296    <div class="card" style="margin: 20px 0;">
    227297      <div class="card-body">
  • jne-shipping-official/trunk/composer.json

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

    r3415143 r3416278  
    2020 * Plugin Name:       JNE Shipping Official
    2121 * Description:       WordPress plugin integrated with WooCommerce for JNE shipping services
    22  * Version:           1.2.2
     22 * Version:           1.3.0
    2323 * Author:            PT. Tiki Jalur Nugraha Ekakurir
    2424 * Author URI:        https://jne.co.id/
     
    4848 * Rename this for your plugin and update it as you release new versions.
    4949 */
    50 define('JNESHOF_PLUGIN_VERSION', '1.2.2');
     50define('JNESHOF_PLUGIN_VERSION', '1.3.0');
    5151
    5252/**
  • jne-shipping-official/trunk/readme.txt

    r3415143 r3416278  
    44Tags: shipping, woocommerce, jne, indonesia, courier
    55Requires at least: 5.0
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.2.2
     8Stable tag: 1.3.0
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    9090
    9191== Changelog ==
     92
     93= 1.3.0 =
     94* Added: Priority system for Shipping Cost Adjustments - Rules are now automatically prioritized based on specificity (District > City > Province > Service)
     95* Added: Information panel in Shipping Cost Adjustments page explaining how rules priority works
     96* Improved: Character length validation for tracking number generation - All fields now respect API documentation limits and automatically truncate if exceeded
     97* Fixed: String truncation handles multibyte characters correctly using mb_strcut for proper byte-based truncation
     98* Enhanced: User experience with collapsible info box showing priority rules explanation
    9299
    93100= 1.2.2 =
     
    188195== Upgrade Notice ==
    189196
     197= 1.3.0 =
     198Major update: Enhanced Shipping Cost Adjustments with intelligent priority system. Rules are now automatically prioritized based on specificity (most specific rule wins). Added character length validation for API compliance. All tracking number fields are now automatically truncated to match API documentation limits. Includes new user-friendly information panel explaining how rules priority works. Recommended for all users.
     199
    190200= 1.2.2 =
    191201Bug fixes and improvements: Fixed CTC service labeling (now displays as REG), improved dashboard calculations, fixed SKU display in shipping labels, and added pickup request validation. Recommended for all users.
Note: See TracChangeset for help on using the changeset viewer.