=== Mora Delivery for WooCommerce ===
Contributors: moralogistics
Tags: shipping, delivery, woocommerce, nigeria, cash on delivery
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.7.80
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires Plugins: woocommerce

Live Mora delivery quotes at checkout, a delivery-fee-now / goods-on-delivery payment gateway, and order sync with Mora Logistics.

== Description ==

Mora Delivery for WooCommerce connects a WooCommerce store to Mora Logistics, a delivery and fulfilment service, so a merchant can:

* Show a real, live delivery quote at checkout, priced by Mora's own rate API against the customer's address or pinned location.
* Offer a payment gateway that charges only the order's delivery fee upfront (by card, bank transfer, or USSD through the merchant's own Paystack account), leaving any goods balance to be collected in cash on delivery. By default this works for any order regardless of shipping method. An optional setting restricts it to Mora's own delivery method and Lagos addresses only, for a merchant delivering nationwide who still wants this fee-now/collect-on-delivery flow limited to Lagos; an interstate order with Mora chosen still delivers, it just pays in full upfront through another payment method.
* Automatically push a placed order to Mora and keep its status in sync afterward, so the merchant's own dashboard and Mora's delivery team see the same order without re-entering it anywhere.
* Let a customer pin their exact delivery location (Google Places autocomplete) instead of typing an address Mora's riders might not recognise, with a plain address field as a fallback when that's turned off.

A Mora Logistics merchant account (a real business relationship with Mora, not a generic sign-up) is required for the shipping-quote and order-push features to do anything; the payment gateway can be used on its own by any merchant with a Paystack account. This plugin is currently built and supported for merchants operating in Nigeria.

= What this plugin does not do =

Pricing detail, cost basis, and margin never leave Mora's own servers. This plugin only ever receives a price, whether a destination needs manual confirmation, and whether cash-on-delivery is allowed there, the same information shown to the customer.

== External Services ==

This plugin connects to the following services to provide its features. None of them run unless the matching feature is actually configured and in use.

**Mora Logistics API (mora-api)**: Mora's own backend, used to price delivery quotes and to push and sync placed orders. When a quote is requested, this plugin sends the destination state, and, where available, the customer's pinned coordinates or typed address, to the Mora API address set in the plugin's settings (Mora's production service is `https://api.moralogistics.com`). When an order is placed, order, product, and customer contact details are sent there so Mora can fulfil the delivery. This is Mora's own first-party service, governed by the same merchant agreement a Mora Logistics merchant signs; see Mora Logistics' Terms of Service (https://moralogistics.com/terms) and Privacy Policy (https://moralogistics.com/privacy-policy).

**Paystack**: used only by this plugin's own payment gateway (optional, merchant-enabled), through the merchant's own Paystack account. The order's delivery-fee amount, currency, and a payment reference are sent to Paystack to process the charge (sent to `https://api.paystack.co` when the customer places an order with this gateway, and again to verify the payment); no card details pass through this plugin or site, Paystack's own hosted page handles that directly. See Paystack's Terms of Use (https://paystack.com/terms) and Merchant Privacy Policy (https://paystack.com/privacy/merchant).

**Google Maps / Places API (New)**: used only by the optional checkout address-search widget (merchant can turn this off). When enabled, the customer's browser loads Google's Places library directly and sends the text they type, plus the location they select, to Google, to resolve an address to coordinates. See Google's Terms of Service (https://policies.google.com/terms) and Privacy Policy (https://policies.google.com/privacy). The API key used is Mora's own, centrally managed and rate-limited; the merchant does not need their own Google Cloud account.

**Sentry**: error reporting, off by default. Nothing is sent unless the merchant ticks "Error reports" on the WooCommerce > Mora Delivery settings page. When enabled, this plugin's own warning and error log messages are sent to Mora's Sentry project (`ingest.de.sentry.io`) as they happen, with the site's address and the plugin, WordPress and PHP versions. Customer names, phone numbers, emails and addresses are never sent. See Sentry's Terms of Service (https://sentry.io/terms/) and Privacy Policy (https://sentry.io/privacy/).

== Source code ==

This plugin has no build step: every PHP, JavaScript and CSS file in it is the human-readable source. The short Google Maps loader inside `assets/js/blocks-locator.js` and `assets/js/checkout-autocomplete.js` is Google's official Dynamic Library Import bootstrap snippet, copied verbatim from https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import.

== Installation ==

1. Upload the plugin through Plugins > Add New > Upload Plugin, or extract it into `wp-content/plugins/`.
2. Activate it through the Plugins screen.
3. Go to WooCommerce > Mora Delivery to enter the API key Mora Logistics gave your business, then configure a shipping zone to use the Mora method.
4. Optionally, go to WooCommerce > Settings > Payments > Mora Goods on Delivery to enable the delivery-fee-now payment gateway.

== Frequently Asked Questions ==

= Do I need a Mora Logistics account to use this plugin? =

For live shipping quotes and order sync, yes, a real merchant relationship with Mora Logistics. The delivery-fee payment gateway can be used on its own without one, as long as you have your own Paystack account.

= Does this work outside Nigeria? =

Not currently. Mora Logistics operates in Nigeria, and this plugin's shipping-quote and address features are built around Nigerian states and addresses.

= What happens to the goods balance if a customer pays the delivery fee online? =

It's collected in cash when the order is delivered. The order shows the outstanding balance in wp-admin, and there's a one-click action to mark it collected once the rider hands it over.

== Screenshots ==

1. The delivery fee shown live at checkout, before the customer pays.
2. The delivery-fee-now payment gateway at checkout.
3. The Mora Delivery settings screen in wp-admin.

== Changelog ==

= 0.7.80 =
* The Plugins screen now shows "By Mora Logistics" and a plain-language description.

= 0.7.79 =
* Fixed: hub-pickup orders from the block checkout (WooCommerce Local Pickup) were never sent to Mora. They are now, like classic-checkout pickup orders.
* Docs: External Services no longer says payments are verified through Mora's API (they are verified directly with Paystack), and names the configured API address.

= 0.7.78 =
* Fixed: an unpaid on-hold order (for example, bank transfer awaiting payment) is no longer sent to Mora. It is sent once you mark it processing.

= 0.7.77 =
* Fixed: with "Restrict to Lagos" on, choosing "Pay delivery fee now, balance on delivery" on a Mora delivery to Lagos could show "not available for this order" on the block checkout.

= 0.7.76 =
* Error reporting to Sentry is now opt-in and off by default (WooCommerce > Mora Delivery > Error reports).
* The "stock Cash on Delivery is still enabled" notice now only shows on WooCommerce's Payments settings, and only when the Mora Goods on Delivery gateway is enabled.
* Fixed a PHP notice on Blocks checkout field registration (maxLength attribute name).
* Readme: corrected the Paystack privacy policy link, documented the source of the Google Maps loader snippet, and clarified what is sent to Paystack and Sentry.

= 0.7.75 =
* Removed the "Tested up to" line from the plugin header (WordPress.org requires it be declared only in this readme file, to avoid the two silently drifting apart).

= 0.7.74 =
* Code comments no longer reference this project's internal development-notes file by name. No functional change.

= 0.7.73 =
* The "Restrict to Lagos" setting on the goods-on-delivery gateway now also requires Mora's own shipping method to be the one chosen (not just a Lagos destination); an interstate order with Mora chosen still delivers, it just pays in full upfront through another payment method instead of this gateway's fee-now/collect-on-delivery flow.

= 0.7.72 =
* Shortened the 0.7.68 upgrade notice to meet WordPress.org's 300-character limit for it.

= 0.7.71 =
* Added an opt-in "Restrict to Lagos" setting on the goods-on-delivery payment gateway, for a store delivering nationwide that still wants this gateway's own cash-on-delivery handoff limited to Lagos.

= 0.7.69 =
* Fixed a fatal error (infinite recursion) that could crash checkout and cart pages when the site-wide API key is unset and a shipping zone still has a Mora method configured.

= 0.7.68 =
* Plugin slug renamed to mora-delivery-for-woocommerce (from mora-woocommerce), to meet WordPress.org's plugin-directory naming rules.
* Internationalization fixes: translator comments and ordered placeholders on two order-push log messages and the Delivery Failed status label.
* An exception message is now escaped before being thrown.
* The build script is no longer bundled into the distributed plugin zip.

= 0.7.67 =
* The delivery-fee payment gateway no longer depends on Mora's own shipping method being chosen; it now works for any order, any shipping method, any destination, as a plain opt-in setting.

= 0.7.0 - 0.7.66 =
* Blocks (Cart & Checkout block) support for the shipping quote, the locator widget, and the payment gateway, alongside classic checkout.
* Checkout lead capture, order push and status sync, delivery-status webhooks, Sentry error reporting (optional), and a long series of live-diagnosed fixes to the Blocks checkout address/state fields. Full detail kept in this repository's own development history, not repeated here.

= 0.6.x and earlier =
* Initial shipping-quote integration, goods-on-delivery payment gateway, and order push, built out across the Rate API and Merchant Intake build order.

== Upgrade Notice ==

= 0.7.68 =
This version's slug changed to mora-delivery-for-woocommerce. WordPress treats it as a different plugin: deactivate and delete the old install first, then install this zip fresh. Your stored settings (API key, webhook secret) are kept and unaffected.

= 0.7.67 =
If you use the delivery-fee-now payment gateway, double check WooCommerce > Settings > Payments > Mora Goods on Delivery after updating: it is no longer restricted to Mora's own shipping method, so it may now appear on orders it previously didn't.
