=== ShopMap Connector ===
Contributors: mahdikhorshidi
Tags: woocommerce, reports, profit, inventory
Requires at least: 6.2
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 0.15.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connects a WooCommerce store to the ShopMap service (shopmap.ir). Store data stays on your own site.

== Description ==

ShopMap Connector keeps a sales ledger, purchase costs and purchase receipts in its own tables on your WordPress database and lets the ShopMap web app read and update them.

* The ledger holds order numbers, amounts, product ids and quantities, plus the customer's name and phone number (or email) so you can see sales per customer. Customer details are shown only to signed-in members of your own store, directly from your site to their browser. They are never sent to ShopMap servers.
* Only the ShopMap account you approve on the settings page can read it.
* Every request must carry a short-lived permit signed by ShopMap. The plugin checks the signature locally with a public key; it stores no secret and makes no outgoing calls.
* One click disconnects ShopMap at any time.

This plugin is a connector: reports, calculations and the dashboard are provided by the ShopMap service, which requires a paid account.

== External services ==

This plugin makes no outgoing calls. It answers requests coming from the browser of a signed-in ShopMap user (https://shopmap.ir), limited to the origin and account configured on the settings page. To calculate profit, that browser sends order amounts, product ids, quantities and purchase costs (no customer data) to the ShopMap service, which returns the result without storing it. Once a day the ShopMap server itself reads store-health figures (counts and numbers of orders stuck in one status, daily sales totals, low-stock products, items sold below cost, coupons without expiry or usage limit) with a permit limited to that purpose; no customer data is included. Terms: https://shopmap.ir/terms — Privacy: https://shopmap.ir/privacy

== Fast path ==

Optionally (one click, off by default) the plugin copies a single file to wp-content/mu-plugins so ShopMap read requests are answered before the theme and other plugins load. It is removed on deactivation.

== Changelog ==

= 0.15.0 =
* Health: current price and stock of chosen products (numbers only), so ShopMap can compare them with what Torob shows.

= 0.14.0 =
* Setup progress route (counts only) used by ShopMap to verify onboarding rewards.

= 0.13.0 =
* Customers: all-time view, filtering by customer segment (the segment rules are defined by ShopMap and sent as plain numbers), lifetime totals and site-member flag per customer.
* Customer profile: lifetime sales and profit, sales by channel, order history, member since, and addresses from the latest order. Customer details go only to signed-in members of the store, directly from the site to their browser.

= 0.12.0 =
* New invoice: shipping methods and costs come from WooCommerce's own shipping zones. The chosen WooCommerce method is saved on the order, so reports and shipping plugins recognise it. Formula costs are shown as-is for manual entry.

= 0.11.0 =
* Printable A4 invoice for any order: shop details from WordPress and WooCommerce settings, buyer and shipping address, line items with variation attributes, discounts, shipping, fees and totals. Buyer details go only to signed-in members of the store, directly from the site to their browser.

= 0.10.0 =
* All WooCommerce orders in ShopMap, with every status (including statuses added by other plugins such as Basalam), status tabs with counts and search by number, name, phone or email.
* Change an order's status from ShopMap. It goes through WooCommerce itself, so stock, customer emails and other plugins behave exactly as when the status is changed in the dashboard, and an order note is added.

= 0.9.0 =
* Edit products from ShopMap: regular and sale price, stock quantity, stock management and SKU, for simple products and variations. Saved through WooCommerce's own product API, so lookup tables, caches and stock status stay in sync.
* Product list now includes image, category and links to edit or view each product, and can be filtered by category.

= 0.8.0 =
* Store health: tells ShopMap the real checkout page address (which may be translated or renamed) so site availability is checked on the right page.

= 0.7.0 =
* Basalam orders are recognised by their "(باسلام)" order statuses and counted as sales (except cancelled or returned ones). When WooCommerce shows their origin as "Unknown", the origin is filled in as Basalam in WooCommerce's own order attribution fields; an origin that is already set is never changed. Can be turned off with the shopmap_fill_order_origin filter.
* New sales channels from WooCommerce order attribution: Instagram (source ig / instagram) and Google organic search.
* All orders are re-read once in the background after the update so existing orders get the right channel.

= 0.6.0 =
* Purchase costs now live in WooCommerce's own "Cost of goods" field (Cost of Goods Sold feature) instead of a separate table. Existing costs are copied over once; a product that already has a WooCommerce cost is left untouched.
* The store currency is read once from WooCommerce and re-read only when it is changed in WooCommerce settings. Rial, toman, thousand rial and thousand toman are supported.
* Store health: low stock among recent sellers, items sold below cost, and coupons without expiry or usage limit.

= 0.5.0 =
* Store health: read-only routes for stuck orders and daily sales totals, available only to a permit with the separate "health" scope. Orders are read through WooCommerce's order query, so both HPOS and legacy storage work.

= 0.4.0 =
* Create in-store and delivery invoices from ShopMap as native WooCommerce orders, with safe stock reservation; order details; barcode and customer lookup.

= 0.3.0 =
* Per-product and per-customer sales reports, internal EAN-13 barcodes and label lists, estimated profit for products without a purchase cost.

= 0.2.0 =
* Order ledger with line items (no customer data), purchase costs, purchase receipts, channel fees.
* Profit figures are computed by the ShopMap service and stored here; the plugin contains no pricing or costing logic.

= 0.1.0 =
* First test build: daily summary, standard REST route, optional fast path.
