=== Shipping Labels for DHL eCommerce APAC ===

Author: Algoleap Technologies Pvt Ltd
Contributors: dhlecommerceasia
Tags: shipping, ecommerce, woocommerce, labels, dhl-shipping, tracking, webhook
Requires at least: 6.0
Tested up to: 6.6
Stable tag: 1.1.5
Requires PHP: 7.4
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
WC requires at least: 3.0
WC tested up to: 9.1.0
WC HPOS Compatible: true
Integrate DHL eCommerce APAC shipping services with your WooCommerce store. Supports High-Performance Order Storage (HPOS) and automated tracking updates through Webhooks.

== Description ==

The **Shipping Labels for DHL eCommerce APAC** plugin, developed by **Algoleap Technologies Pvt Ltd**, automates your shipping workflow by connecting your WooCommerce store to DHL eCommerce APAC services — with full support for **WooCommerce HPOS** and now **automatic tracking status updates via Webhooks**.

### Key Features ###
- Generate and print shipping labels directly from WooCommerce admin.
- Automatically track shipments and update order status via Webhooks.
- Offer DHL shipping options at checkout.
- Calculate accurate shipping rates based on destination, weight, and dimensions.
- Supports WooCommerce HPOS (High-Performance Order Storage).
- Easy-to-use interface for generating and printing shipping labels.
- Seamless integration with WooCommerce checkout process.
- Detailed documentation and support available.

== New in Version 1.1.5 ==
- **Webhook Endpoint Added:** A REST API endpoint `/wp-json/dhl-apac/v1/tracking-webhook` is now created automatically when the plugin is activated.
- **Automatic Shipment Tracking Updates:** DHL’s ELR system can send parcel status updates directly to this endpoint, updating the order’s Tracking Status column in real time.
- **Dynamic Webhook Registration:** The webhook endpoint is automatically available on every customer’s WordPress site upon plugin installation — no manual setup required.
- **Enhanced Logging:** Webhook payloads and responses are securely logged for debugging and traceability.
- **Improved Order Overview:** Added new columns for **Shipment ID** and **Tracking Status** in the WooCommerce Orders page.

- **Company Name Limit Increased:** The Company Name field now supports up to **60 characters** (previously 30).  
- **Address Line Limits Updated:**  
  - Address Line 1 increased to **60 characters**  
  - Address Line 2 increased to **120 characters**  
  - Implemented improved splitting + overflow handling as per DHL specifications  
- **Improved User Experience:** After logging in, customers using the DHL APAC plugin are automatically redirected to the **DHL Configuration Page** instead of the site homepage.  

== Installation ==

1. Upload the plugin to `/wp-content/plugins/shipping-labels-dhl-ecommerce-apac`, or install via the WordPress plugin screen.
2. Activate it via **Plugins > Installed Plugins**.
3. Go to **WooCommerce → Settings → Shipping → DHL eCommerce APAC** to configure.

**Note:** Always back up your site before updating the plugin.

== Configuration ==

1. Enter your **DHL eCommerce APAC API credentials**.
2. Configure your default package dimensions and shipping preferences.
3. Enable **Webhook tracking updates** (enabled automatically).
4. Enable debug logging if needed.

== Usage ==

### Creating Shipping Labels
1. Go to **WooCommerce → Orders**.
2. Open any order and find the “DHL eCommerce APAC” panel.
3. Fill in shipping details and click **Generate Label**.
4. Download and print the generated label.

### Bulk Label Creation
1. Go to **WooCommerce → Orders**.
2. Select multiple orders.
3. Choose **Create DHL eCommerce APAC Labels** from the Bulk Actions dropdown.

### Automatic Tracking Updates
- DHL’s ELR system automatically sends tracking updates to your webhook endpoint.
- The WooCommerce order table updates the **Tracking Status** automatically.

## WooCommerce HPOS Compatibility ##
Fully compatible with WooCommerce High-Performance Order Storage.

## Privacy & Logging ##
Webhook and API logs are stored securely in WooCommerce → Status → Logs (when enabled).

## Disclaimer ##
This plugin is an independent DHL eCommerce APAC integration and is not officially endorsed by DHL.

## Frequently Asked Questions ##

### Does this plugin support automatic tracking updates?  
Yes — tracking updates are pushed directly by DHL to your webhook endpoint.

### Do I need to manually configure the webhook?  
No — it is registered automatically when the plugin is activated.

### Does this work with HPOS?  
Yes, the plugin is fully compatible.

## Support ##
Contact the WordPress plugin support forum or plugins@wordpress.org.

## Changelog ##

1.1.5
Added: Automatic webhook endpoint for real-time tracking updates from DHL.  
Added: Dynamic webhook registration during plugin activation.  
Improved: Automatic update of "Status” in WooCommerce Orders.  
Enhanced: Logging for webhook requests and responses.  
Tested: WooCommerce 9.1.0 & WordPress 6.6

Added: Company Name field now supports 60 characters.  
Updated: Address Line 1 (60 chars) & Address Line 2 (120 chars) limits with enhanced splitting logic.  
Improved: User login redirection directly to the DHL Configuration page when the plugin is active.

1.1.4
Fixed: Replaced all error_log() calls with him_dhl_bulk_order_log_msg().  
Improved: Bulk label API requests and responses logging.  
Fixed: Ensured API responses save metadata only after proper validation.  
Improved: Return address fallback logic to prevent invalid API data.  

1.1.3
Fixed: Shipper address handling during bulk label creation.  
Improved: Unified bulk label logging system.  
Fixed: Missing error details in bulk creation logs.  

1.1.2
Improved: Stability and bug fixes.  
Enhanced: Full compatibility with HPOS.  
Added: Support for bulk label ZIP download.  
Updated: Metadata handling for HPOS tables.  
Improved: Session management during label creation.  

1.1.1
Fix: Added messageSource parameter in API requests.

1.1.0
Fix: Weight calculation adjustments.

1.0.9
Fix: Company name is now optional.

1.0.8
Fix: Limited package description to 50 characters.

1.0.7
Fix: Copied shipping details from billing details when only billing exists.  
Fix: Shipping details now populate correctly.

1.0.6
Fix: Conflict with Sequential Order Numbers plugin.

1.0.5
New: Cash on Delivery support improvements.

1.0.4
Fix: Corrected Address Line 1 mapping.

1.0.3
Fix: Populated Remark field with Package Description.  
Fix: Updated tracking URL.

1.0.2
Fix: CSS improvements.

1.0.1
New: Shipper address change implementation.  
New: Error logging for label creation.  
Fix: CSS issues.

1.0.0
Initial release.

**Note:** Before updating the plugin, we strongly recommend backing up your site (files and database) to avoid data loss in case of compatibility issues.