=== MotorHangar for WooCommerce ===
Contributors: motorhangar
Tags: woocommerce, cars, car dealer, inventory, vehicles
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
WC requires at least: 7.0
WC tested up to: 9.9
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Publish the cars of your WooCommerce store on MotorHangar and keep them in sync: new cars, price changes, sold and withdrawn cars.

== Description ==

MotorHangar is a free marketplace for car dealers. This plugin publishes the cars you sell in your WooCommerce store on MotorHangar and keeps every listing up to date, so you only manage your stock in one place.

* **Realtime:** when you create or edit a car, its listing is updated within minutes. When you unpublish, trash or delete it, the listing is withdrawn. When it goes out of stock it is marked as sold (or withdrawn, or left alone: you choose). When it is back in stock it is published again.
* **Daily reconciliation:** once a day every car is sent again and MotorHangar is told which cars the store still has, so a sale that a missed hook did not report is caught.
* **Safe by design:**
  * A store that suddenly lists zero cars never marks your listings as sold.
  * If more than 40% of your listings would be marked as sold at once, MotorHangar refuses and the plugin asks you to confirm instead of doing it.
  * Missing data is never invented: a car without a brand, model, year or price is reported on the product, not guessed.
* **Flexible field mapping:** brand, model, year, version, mileage, fuel, transmission, colour, condition and city can each come from a product attribute (global or custom), a custom field (meta key), or the MotorHangar box on the product.
* **Background processing:** the API is never called while you save a product. Everything goes through Action Scheduler (bundled with WooCommerce), with retries and rate-limit handling.
* **WP-CLI:** `wp motorhangar sync [--dry-run]` and `wp motorhangar status`.

Changes travel one way only: from your store to MotorHangar. Nothing on MotorHangar ever changes your store.

= What is sent =

* Price: the active WooCommerce price (the sale price while a sale is on), in the store currency.
* Photos: the featured image followed by the gallery, full size, up to 10.
* Description: the short description, or the description when it is empty, as plain text (2000 characters at most).
* Stock id: the product ID, or the SKU if you prefer (the product ID is used when a product has no SKU). The same id always means the same car.

== External services ==

This plugin connects to the MotorHangar Inventory API (https://motorhangar.com/api/v1) to publish, update, withdraw and mark as sold the cars of your store, and to read your dealer account, your market's vocabulary and the brand/model catalog.

It sends, for each car you choose to publish: its stock id, brand, model, year, version, price, currency, mileage, fuel, transmission, colour, condition, city, description and the public URLs of its photos. It sends your API key in the Authorization header of every request. No data about your customers or orders is ever sent.

Data is sent when you save a product, when its stock changes, once a day for the reconciliation, and when you click "Sync now" or "Test connection".

MotorHangar terms of use: https://motorhangar.com/terms/ — privacy policy: https://motorhangar.com/privacy/

== Installation ==

1. Install and activate WooCommerce (7.0 or later).
2. Upload the `motorhangar-for-woocommerce` folder to `/wp-content/plugins/`, or install the zip from Plugins > Add New > Upload.
3. Activate the plugin.
4. In your MotorHangar dealer panel, open API keys (https://motorhangar.com/account/dealer/api/) and create a key (it starts with `mh_`). Copy it: it is shown once.
5. Go to WooCommerce > MotorHangar, paste the key, click "Save Changes" and then "Test connection".
6. Choose the market, which products to publish and where each field comes from.
7. Click "Sync now", or wait for the daily sync.

== Frequently Asked Questions ==

= Which products are published? =

You choose: only the products where you tick "Publish on MotorHangar", all products of one category (and its subcategories), or every published product. Drafts, private, pending and trashed products are never published.

= A car shows "Error" in the products list. What now? =

Open the product: the MotorHangar box says exactly what is missing or rejected (for example "brand is missing" or "unknown model"). Brand and model must exist in the MotorHangar catalog; the box suggests the valid names as you type.

= Will the plugin mark all my cars as sold if something goes wrong? =

No. If the store returns no cars, if any batch could not be sent, or if the change would mark more than 40% of your listings as sold, nothing is marked as sold. In the last case you get a notice in the admin and can confirm it if those cars really were sold.

= Can I change the stock id from product ID to SKU later? =

Yes, but every car will be published again under its new id and the old listings will be withdrawn. Do it before your first sync if you can.

= My store measures mileage in kilometres but the market uses miles. =

Set "Mileage in this store is in" to kilometres and the plugin converts it.

= I sell in more than one country. =

One store publishes in one market, chosen in the settings.

= Where are the logs? =

WooCommerce > Status > Logs, source `motorhangar`. The API key is never written to the log.

= What happens when I uninstall the plugin? =

Its settings, caches, queued tasks and product data are deleted. Your listings on MotorHangar are not touched: withdraw them from the dealer panel if you want them gone.

== Changelog ==

= 1.0.0 =
* First release: realtime sync through Action Scheduler, daily reconciliation, field mapping, product meta box and status column, WP-CLI commands.

== Upgrade Notice ==

= 1.0.0 =
First release.
