=== AiGesta CRM for WooCommerce ===
Contributors: aigestacrm
Tags: crm, orders, woocommerce, utm, sales
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sends every new WooCommerce order to AiGesta CRM: customer, products by SKU, shipping, payment and UTM tags. No code needed.

== Description ==

[AiGesta CRM](https://aigestacrm.com) is a cloud CRM for online stores: orders from the website, marketplaces and chats in one list, customers, warehouse, deliveries, finances and analytics.

This plugin connects your WooCommerce store to AiGesta CRM. Every new order appears in the CRM a second after checkout:

* customer — name, phone, email, city and address or pickup point;
* products — matched with the CRM catalog by SKU, so stock is written off automatically;
* shipping method and cost, payment method (cash on delivery is recognised), coupon and discount;
* order note and the WooCommerce order number;
* advertising tags (utm_source, utm_medium, utm_campaign, utm_content, utm_term) and the landing page — the CRM shows which ad brought the sale.

Works with the classic and the block checkout, and with High-Performance Order Storage (HPOS).

If the CRM is temporarily unavailable, the plugin retries the order three times, five minutes apart. Any order can also be sent by hand: Orders → open the order → Order actions → «Send to AiGesta CRM».

Optionally, the CRM can load your **past orders** for a chosen period (for example, the last year) — enter the export key on the settings screen.

The plugin interface is available in English, Ukrainian and Russian.

== Installation ==

1. In WordPress go to Plugins → Add New, search for «AiGesta CRM for WooCommerce», install and activate it. WooCommerce must be active.
2. In AiGesta CRM open Settings → Integrations → Website and turn on receiving orders. Under «Website on WordPress (WooCommerce)» open «Keys for manual setup» and copy the form key (and, if you want to load past orders, the export key).
3. In WordPress open WooCommerce → AiGesta CRM, paste the keys and click Save.
4. Place a test order on your site — it will appear in the CRM under Orders with the source «Website».

You can also download the plugin with the keys already filled in from the same CRM screen («Download the module for WooCommerce») and upload it on Plugins → Add New → Upload Plugin.

== Frequently Asked Questions ==

= Do I need an AiGesta CRM account? =

Yes. The plugin only sends orders to your store's account in AiGesta CRM. You can register at https://aigestacrm.com — there is a free trial.

= Where do I find the keys? =

AiGesta CRM → Settings → Integrations → Website → «Website on WordPress (WooCommerce)» → «Keys for manual setup». Only the store owner and administrators see the keys.

= An order did not reach the CRM. What should I do? =

Open WooCommerce → AiGesta CRM: the last error is shown at the top of the screen (for example, a wrong key). Fix it and send the order again: open the order → Order actions → «Send to AiGesta CRM».

= Will an order be sent twice? =

No. After the CRM accepts an order, its CRM number is saved in the order (and shown in the order notes), and the order is never sent again.

= I installed the module downloaded from my CRM earlier (version 1.1 or older). =

Install this plugin: it picks up the keys from the old module, switches the old module off and continues sending orders. Orders that were already sent are not sent again. Then you can delete the old «AiGesta CRM — замовлення WooCommerce» plugin.

= Can I turn sending off for a while? =

Yes: WooCommerce → AiGesta CRM → untick «Send orders». Orders can still be sent by hand from the order screen.

== External services ==

This plugin connects to AiGesta CRM (https://aigestacrm.com), a cloud CRM service, to deliver your store's orders to your CRM account. Nothing is sent until you enter your form key, or install the copy downloaded from your CRM, which already contains the key.

* **When a customer places an order**, the plugin sends it to `https://aigestacrm.com/api/site-order`: the customer's name, phone, email, city and shipping address, the order note, products (name, SKU, price, quantity), shipping and payment method, coupon and discount, the WooCommerce order number, UTM tags and the landing page and referrer of the visit. The form key identifies your store.
* **When the CRM loads past orders** (only if you entered the export key), the CRM requests `/?rest_route=/aigesta/v1/orders` on your site with the export key in the `X-AiGesta-Key` header and receives the same order data for the requested period. Requests without the correct key are rejected.

To remember UTM tags, the plugin sets two first-party cookies on your site for 30 days: `aigesta_utm` (UTM tags from the page address) and `aigesta_land` (landing page and referrer). They are not sent anywhere except with an order.

The service is provided by AiGesta: [Terms of service](https://aigestacrm.com/terms), [Privacy policy](https://aigestacrm.com/privacy).

== Screenshots ==

1. Settings: WooCommerce → AiGesta CRM — form key, export key and the status of the last order.
2. A WooCommerce order in AiGesta CRM: customer, products, shipping, payment and the ad that brought the sale.
3. AiGesta CRM → Integrations → Website: the keys and the download of the plugin with the keys filled in.

== Changelog ==

= 1.2.0 =
* Published in the WordPress.org plugin directory as «AiGesta CRM for WooCommerce».
* Keys are entered on the settings screen (WooCommerce → AiGesta CRM); a copy downloaded from the CRM still comes with the keys filled in.
* New setting: export key for loading past orders.
* Interface in English, Ukrainian and Russian.
* Takes over from the old module (aigesta-crm): moves the keys and switches it off.
* Security: stricter input checks, the past-orders endpoint checks the key in its permission callback.

= 1.1.0 =
* Past orders for a period on request from the CRM; coupons and discounts.

= 1.0.0 =
* First version: new orders go to AiGesta CRM, UTM tags, retries, «Send to AiGesta CRM» order action.

== Upgrade Notice ==

= 1.2.0 =
Keys now live in the settings. If you installed the module from your CRM before, they are moved automatically.
