=== MultiOrder Sync For WooCommerce ===
Contributors: kiranms1996
Tags: multiple, order, sync, link orders, woocommerce
Requires at least: 5.0
Tested up to: 6.8
Stable tag: 1.1.0
Requires PHP: 7.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

A plugin to manage and link multiple WooCommerce orders based on custom criteria.

== Description ==
MultiOrder Sync For WooCommerce allows store owners to group and link WooCommerce orders based on criteria like customer ID, billing email, or address. Features include:
- Grouping orders automatically based on customizable criteria.
- Linking orders into parent and sub-order relationships.
- Email notifications for order status changes.
- REST API for fetching orders.
- Admin interface for managing groups and settings.

== Installation ==
1. Upload the `emw-multiple-order-management` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Navigate to 'Muilti-Order' in the admin menu to configure settings and manage orders.

== Frequently Asked Questions ==
= Does this plugin require WooCommerce? =
Yes, WooCommerce must be installed and active.

= Can I customize the email notifications? =
Yes, the Notifications tab allows you to customize the email subject and template.

= Does it support WordPress Multisite? =
Yes, the plugin can fetch and manage orders across subsites using the REST API.

== Screenshots ==
1. Admin page showing order groups.
2. Group details popup for linking orders.
3. Settings page for configuring order statuses and criteria.

== Features ==
- Automatically group WooCommerce orders based on criteria like customer or address.
- Manually link and split orders.
- Prevent duplicate fulfillment by grouping related orders.
- View and manage order groups from the admin interface.
- REST API for external integrations (CRM, ERP, fulfillment).
- Customizable email templates for order group updates.
- Multisite compatible – works across subsites.

== REST API ==
This plugin exposes custom REST API endpoints for external access:

1. `/wp-json/emw-mom/v1/orders`  
   Fetch WooCommerce orders with optional filters.  
   **Method:** GET  
   **Header:** `X-EMW-MOM-API-Key: YOUR_API_KEY`

2. `/wp-json/emw-mom/v1/multiple-order-group/<order_id>`  
   Fetch group of orders by individual order ID.  
   **Method:** GET  
   **Header:** `X-EMW-MOM-API-Key: YOUR_API_KEY`

== Developer Notes ==
You can extend the plugin using the following hooks and filters:
- `emw_mom_order_group_created`
- `emw_mom_order_linked`
- `emw_mom_api_key_validated`
- ...and more.

== Changelog ==

= 1.2.0 - 2025-08-22 =
* Changed: Plugin name updated to **MultiOrder Sync**.
* Changed: All references to "Primary Order" have been renamed to **Parent Order**.
* Changed: All references to "Secondary Order" have been renamed to **Linked Order**.
* Changed: Updated admin labels, meta keys, API fields, and internal function names to reflect new terminology.
* Changed: Improved consistency in database schema and UI components related to order relationships.
* Fixed: Minor translation and text domain issues caused by renamed labels.

= 1.1.0 - 2025-08-18 =
* Changed: Unified `multipleorders` meta structure for all linked orders.
* Changed: Improved `ajax_link_orders` and `ajax_unlink_orders` functions to reflect accurate linked/unlinked state for each order.
* Changed: Updated `render_settings_page()` method to load settings tabs using PHP instead of JavaScript.
* Changed: Admin settings UI now loads only the active tab's content for better performance.
* Changed: Refactored tab template loading using a `switch` statement in `render_settings_page()`.
* Changed: Updated settings page navigation to use server-rendered tabs with persistent URLs.
* Changed: Improved Linked Orders meta box UI for clarity and usability.
* Deprecated: Legacy meta structure fallback for backward compatibility (to be removed in a future release).
* Fixed: Admin UI now displays correct linked order metadata across all views.

= 1.0.0 - 2025-08-13 =
* Initial release of the MultiOrder Sync plugin.
* Ability to group WooCommerce orders based on customizable criteria.
* Link grouped orders into parent/sub-order relationships.
* Admin UI for managing grouped orders.
* Settings panel for order criteria, email templates, and API key.
* REST API to:
  - Fetch all orders grouped by site: `/wp-json/emw-mom/v1/orders`
  - Get multiple order group by order ID: `/wp-json/emw-mom/v1/multiple-order-group/{order_id}`
* Multisite support for fetching orders from all network sites.
* API authentication via API key (`X-EMW-MOM-API-Key`).
* Toggleable API documentation in plugin admin settings.
