=== OuiGoo Delivery ===
Contributors: ouigoo
Tags: woocommerce, delivery, shipping, checkout, gps
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.9.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Collects delivery details at the WooCommerce checkout and sends orders to the OuiGoo delivery platform.

== Description ==

In much of West Africa a street address is not how anyone is found. Deliveries
are made to a point on a map, a landmark, a phone call. OuiGoo Delivery asks the
shopper for what a courier actually needs, then hands the order to the OuiGoo
platform without the merchant re-typing anything.

Features:

* Delivery location: a GPS point picked on a map, or address autocomplete.
* A delivery time slot chosen by the shopper.
* Extra instructions — floor, landmark, gate code.
* A shipping method priced from the real coordinates, not from a flat rate.
* Orders sent to OuiGoo in the background, with retries.
* Delivery status pushed back from OuiGoo: the courier's name, the pickup code,
  a timestamped note on the order, and the order marked complete on delivery.
* Sync status visible on the order screen and in the orders list.

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

A OuiGoo Business account is required. The plugin is the connector; the delivery
service, the couriers and the pricing are OuiGoo's.

== Installation ==

1. Install and activate the plugin.
2. Go to WooCommerce → OuiGoo Delivery.
3. Paste the API key generated at https://business.ouigoo.co and link the shop.
   The key identifies your business on its own — there is nothing else to enter.
4. Add "OuiGoo Delivery" to your shipping zones.
5. Optionally set your pickup point, which is what delivery is priced from.

Your shop needs to be reachable over public HTTPS for OuiGoo to push delivery
status back to it. Without that it still works — orders are sent, rates are
calculated — but statuses will not come back on their own.

== Frequently Asked Questions ==

= Does it work with the block checkout? =

Yes. From WooCommerce 8.9 the fields go through the official Additional Checkout
Fields API, which feeds the block checkout and the classic one alike. On older
versions the plugin falls back to the classic checkout hooks by itself.

= What happens if the OuiGoo API is unavailable? =

Nothing that blocks the shopper. Orders are sent in the background, outside the
purchase flow, with five spaced-out retries. If the map fails to load, the
shopper can still type an address.

= Is my Google Maps key exposed? =

The Maps key is necessarily present in the page, as it is for any Google map.
Restrict it to your domain in the Google Cloud console. Your OuiGoo API key is
different: it never leaves the server, and address searches go through an
internal proxy.

= Does it work with WordPress's privacy tools? =

Yes. WooCommerce exports and erases orders, but only its own fields — anything
a plugin stores alongside them is invisible to both. This one adds its own:
a data export includes the delivery point, its coordinates and the delivery
instructions, and an erasure request removes them, along with the stored place,
the signature and the courier's phone number.

The tracking number, the delivery fee and the delivery status are kept. They
identify nobody, and they are your record of a delivery that really happened.

The plugin also offers wording for your privacy policy, which you will find in
the draft WordPress prepares for you under Settings → Privacy.

= What happens to my data if I delete the plugin? =

Settings, API key, signing secret and caches are removed. Delivery details on
orders you have already received are kept — those are your records, not the
plugin's leftovers.

== External services ==

This plugin is a connector: it does nothing without the OuiGoo delivery
platform, which is a third-party service. Installing it means sending data
there. Here is what, and when.

**OuiGoo API** — https://api.business.ouigoo.co

No call is made until you paste your API key into the plugin settings. From
then on, the following is sent:

* When linking the shop, and after that at most once an hour and only if one of
  these values changed: your shop's name, its web address, and the URL OuiGoo
  should call back with delivery updates.
* When a rate is calculated, while the shopper is checking out: the delivery
  point they just chose, and your pickup point.
* When an address is searched: the text the shopper typed into the location
  field.
* When an order is sent: its number, total and line items, along with the
  customer's name, phone number and delivery point.

Nothing is sent for a visitor who does not order, and the plugin sends no usage
statistics of any kind.

Terms and privacy policy: https://business.ouigoo.co

**Google Maps** — https://maps.googleapis.com

Loaded in the shopper's browser, and only if you chose the "GPS point on a map"
mode and supplied your own Google Maps key. It is then your key and your
agreement with Google that apply. In "address autocomplete" mode nothing is
loaded from Google: searches go through the OuiGoo API instead.

Google terms: https://policies.google.com/terms
Google privacy: https://policies.google.com/privacy

== Changelog ==

= 1.9.2 =
* The settings screen's stylesheet and script are now enqueued files rather than markup printed into the page, so WordPress decides when they load and they are absent from every admin screen but ours.
* Removed the call that told WordPress where to find the plugin's translations. Nothing was there to find but the template, and wordpress.org loads translations without it.

= 1.9.1 =
* Fixed: in Safari, declining the location permission — or simply letting it time out — closed the map and left the shopper without it. The map is drawn and perfectly usable on its default centre without the permission, and now stays. It also opens on the delivery country rather than always on Togo.
* If the map genuinely cannot run, the shopper gets address search in the checkout field itself, with suggestions below it. Both return a real point on the map; typed text does not, and an order without one cannot be delivered.
* Fixed: address search only ever looked in the country the page was loaded with. Changing the country on the checkout left the suggestions in the old one, so a shopper switching to Benin kept being offered places in Togo.
* Fixed: choosing a delivery point could snap the country back to whatever it had been a moment earlier, undoing the change that found the address in the first place.
* Fixed: the section heading was shown on checkouts where the delivery fields are not, leaving "Informations nécessaires à la livraison" above nothing but WooCommerce's order note.
* The map's confirm button now takes your theme's button colour whatever that colour is. It used to be borrowed only when white text stayed readable on it, which meant only near-black themes ever got it — a shop with lime green buttons kept an orange one. The text colour is now chosen to suit the background.
* On the cart, where the shopper has not yet chosen a delivery point, the rate could only fall back to your base price — and at zero WooCommerce writes "Free", which is not what it means. The line now reads "tarif calculé après le choix de votre localisation" beside it, on both checkouts. If you would rather show nothing until an address is entered, the shipping method settings now point you at the WooCommerce option that does exactly that.
* Unlinking the shop, or deleting the plugin, now tells OuiGoo as well. The shop used to stay on your linked-shops list forever, pointing at a site that no longer answers. Your API key is not deleted — it goes back to being an ordinary key, so anything else you built on it keeps working.
* Plugin files are now versioned individually, so a fix actually reaches browsers that already have the old copy.

= 1.9.0 =
* Delivery details now take part in WordPress's privacy tools. WooCommerce exports and erases orders, but only its own fields, so everything this plugin stored used to survive an erasure request — including the delivery coordinates, which are a customer's front door to seven decimal places, and the signature taken on delivery. A data export now includes them, and an erasure removes them. The tracking number and the delivery fee are kept: they identify nobody and they are your record of the delivery.
* The plugin now suggests wording for your privacy policy, waiting in the draft under Settings → Privacy.

= 1.8.3 =
* The Google Maps warning on the settings screen now follows what you are doing: pick address autocomplete, or paste a key, and it goes at once instead of waiting for you to save.

= 1.8.2 =
* Fixed: a shop that had installed the plugin but not yet added a Google Maps key could not take orders at all. The map could not load, the location field became a plain text box, and text carries no coordinates — which the checkout requires before it accepts an order. The delivery fields are now left off the checkout entirely until the key is in place, so the shop keeps selling, and the shop manager — and only the shop manager — sees a notice on the checkout explaining why. The settings screen now says how to get a key, with a link.

= 1.8.0 =
* The map picker's confirm button now takes the colour your theme paints its own buttons with, instead of always being orange. The colour is read off a real button on the page, so it follows whatever you set in the site editor — and it is left alone when white text would not be readable on it.
* Map picker updated to 1.0.10.

= 1.7.0 =
* New setting, on by default: OuiGoo sends the customer a WhatsApp message when the order reaches it, carrying the tracking link and the code to give the courier. Turn it off under "Envoi des commandes" if you already message your customers yourself — otherwise they get two messages for one order.

= 1.6.0 =
* Customer phone numbers are now sent to OuiGoo in international form. OuiGoo texts and WhatsApps the customer when a courier is on the way, and a number written the local way — 90 24 11 63 — cannot be reached from either. The country comes from the delivery address, then the billing address, then the point picked on the map, and failing all three from the shop's own country.
* The leading zero is read per country rather than by rule: dropped in Ghana and Nigeria, where it is dialling shorthand, kept in Côte d'Ivoire and Benin, where it is part of the number.
* A number that cannot be reached is now refused at the checkout, while the customer is still there to correct it, instead of surfacing later as an order that will not send.

= 1.5.6 =
* Fixed: on a shop with a long domain name, every order was refused by the API with an unexplained server error. The reference OuiGoo identifies orders by is built from the shop's host, and past a certain length it was rejected — a shop with a long address could never send a single order. Shops whose orders go through today keep exactly the same reference, so nothing is ever sent twice.

= 1.5.5 =
* The map picker is now shipped with the plugin instead of being fetched from a CDN at checkout time. A shop's checkout no longer depends on a third party staying up and serving the same file as yesterday.
* This readme is in English, as the plugin directory requires.
* Housekeeping found by the official Plugin Check tool: input sanitised at the point it is read, direct database queries documented where they are deliberate, and a translation template added.

= 1.5.4 =
* The plugin now cleans up what it wrote when you delete it: settings, API key, signing secret, caches. Delivery details on orders you already received are kept — those are your records, not the plugin's leftovers.
* The external services the plugin contacts are documented in detail in this file.
* On the linking screen, the API's technical address is replaced by a link to business.ouigoo.co, where the key is generated.
* Declared compatibility brought up to date: WordPress 7.1, WooCommerce 11.0.

= 1.5.3 =
* The block checkout grouped our fields under "Additional order information". That heading — and a line beneath it — are now set under "Labels", and tell the shopper these details are what gets them their delivery. A heading typed directly in the Checkout page editor still wins; a setting left blank returns WooCommerce's own default.

= 1.5.2 =
* Fixed: the block checkout saves the field on every keystroke, as a partial update, and the coordinate check refused those saves — every letter typed came back as a 400 error. The check now applies only when the order is placed, the same line WooCommerce draws for its own fields.
* The delivery rate appears about twice as fast after an address is chosen: the place record is fetched while the shopper reads the list, instead of waiting for the click.

= 1.5.1 =
* Fixed: choosing an address from the list immediately triggered a fresh search on the name that had just been inserted, and the list reopened on the choice already made.

= 1.5.0 =
* Address autocomplete now happens directly in the checkout field, with suggestions below it, instead of opening a dialog. Keyboard navigation (arrows, Enter, Escape) and screen-reader announcements.
* If the shopper types text without choosing a suggestion, they are told right away: text alone carries no coordinates, and the delivery could not be dispatched.

= 1.4.1 =
* Fixed: a shop OuiGoo cannot call back (a local or http address) did not register at all, and so never appeared in the list of connected shops. A shop's identity and its callback URL are now two separate things: the shop is always declared, only the callback waits for a reachable address.
* The settings screen separates the two: "Listed at OuiGoo as…" on one side, the state of delivery updates on the other.

= 1.4.0 =
* New: delivery status changes come back into the shop. OuiGoo calls WordPress at every step, the order gets a timestamped note, the courier and pickup code are shown, and the order is marked Completed on delivery.
* The shop declares itself to OuiGoo with its API key — name, address and callback URL in a single call. It now appears under "Settings › Shop" in the OuiGoo dashboard, next to Shopify shops, instead of being an anonymous key. New backend endpoints PUT /v1/store, GET/PUT /v1/webhook and POST /v1/webhook/rotate.
* Incoming calls are signed with HMAC-SHA256 and timestamped; a call replayed more than five minutes later is refused.
* Fixed: looking up an order by shipment id could land on an unrelated order, WooCommerce silently ignoring the filter. The value found is now re-checked.
* Fixed: the tracking link was validated by a method that queries DNS, which could discard a perfectly valid link.

= 1.3.2 =
* Fixed: the re-priced cart returned by the Store API was not passed to the checkout display, which stayed frozen.

= 1.3.1 =
* Fixed: on the block checkout, the location could be saved in a session other than the cart's, leaving the rate at "Free". It now goes through the Store API itself.

= 1.3.0 =
* Major fix: the delivery rate never changed. WooCommerce was reusing the rate it had already calculated, the chosen location not being part of what it compares.
* Rate calculation now requires a pickup address: the two are one feature.
* The block checkout refreshes the rate as soon as the shopper picks their delivery point.
* Removed the warning on order screens, replaced by a check when settings are saved.
* Fixed: the estimated time was divided by 60; the API already gives it in minutes.

= 1.2.1 =
* "Resend to OuiGoo" now sends immediately and reports the result, instead of queueing.
* Fixed: the tracking link saved was not one; the API returns an identifier, not a URL.
* Admin warning when no pickup point is configured, the case where deliveries are priced from a default origin.

= 1.2.0 =
* The delivery location is required as soon as the cart needs shipping, and can no longer be disabled.
* An address with no point chosen on the map is refused: the OuiGoo API requires coordinates.
* Fixed: the session routes did not load the WooCommerce session, and the coordinates chosen by the shopper never reached the order.
* Fixed: cash-on-delivery orders were announced as already paid.
* The delivery date and time is off by default.

= 1.1.0 =
* Place and date pickers moved into modals; no machine data left in a visible field.

= 1.0.0 =
* Initial release.
