=== Delivery Promise for WooCommerce === Contributors: wpruby Tags: woocommerce, delivery date, dispatch date, estimated delivery, shipping Requires at least: 5.6 Tested up to: 6.8 Requires PHP: 7.4 WC requires at least: 6.0 WC tested up to: 9.9 Stable tag: 1.1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.txt Show accurate estimated dispatch and delivery dates across your WooCommerce store based on real store rules. == Description == Delivery Promise for WooCommerce answers your customers' most important question: "When will my order arrive?" It calculates and displays estimated dispatch and delivery dates on the product page, cart, checkout, thank-you page and order emails, based on: * Default processing (handling) and transit times * Same-day dispatch cutoff time * Working days and holidays (weekends and non-working dates are skipped) * Stock status (in stock / out of stock / on backorder) * Shipping method, shipping zone, shipping country * Products, product categories and shipping classes Customers do not choose a date. The plugin displays the merchant's delivery promise. The estimate shown on the order, thank-you page and emails is saved as order meta at checkout, so it stays accurate even if you change your rules later. == Installation == 1. Upload the `wpruby-delivery-promise` folder to `/wp-content/plugins/`. 2. Activate the plugin through the Plugins screen. 3. Go to WooCommerce > Delivery Promise to configure defaults and rules. == Settings == WooCommerce > Delivery Promise has two tabs: * General Settings: enable/disable, default processing/transit times, cutoff time, working days, holidays, date format, display locations and message templates. * Rules: priority-based overrides targeting countries, zone, shipping method, products, categories, shipping classes and stock status. Message template placeholders: `{dispatch_date}` `{dispatch_range}` `{delivery_date}` `{delivery_range}` `{min_delivery_date}` `{max_delivery_date}` `{cutoff_time}` `{shipping_method}` == Admin App (Vue 3) == The admin screen at WooCommerce > Delivery Promise is a Vue 3 single-page app with five sections: General, Rules, Holidays, Messages and Diagnostics. All data is read and written through a REST API namespaced under `wpruby-delivery-promise/v1` (settings, rules, rules/reorder, data, diagnostics and preview). Every write is validated and sanitized server-side; requests require the `manage_woocommerce` capability and a valid REST nonce. The compiled bundle ships in `assets/admin/dist/` (app.js + app.css) and is only enqueued on the plugin admin page. == Build / Development == The admin app source lives in `assets/admin/vue/`. To rebuild after changes: 1. Install Node.js 18+ and run `npm install` in the plugin folder. 2. `npm run build` compiles to `assets/admin/dist/app.js` and `app.css`. 3. `npm run dev` rebuilds on save (watch mode). `node_modules/` and the Vue source are only needed for development; the shipped plugin runs from the compiled `dist/` files and the PHP autoloader (no Composer build step required). == Manual Test Scenarios == These are the manual checks used to verify V1. Baseline: General Settings with Working days Mon-Fri, Cutoff 14:00, Processing 0-1, Transit 2-3. Scenario 1 - Before cutoff: * On a Monday before 14:00, view a product/cart. * Expect dispatch range Mon-Tue and delivery range Wed-Fri. Scenario 2 - After cutoff: * On a Monday after 14:00, view a product/cart. * Same-day dispatch should NOT apply; processing starts Tuesday (dispatch Tue-Wed). Scenario 3 - Holiday skip: * Add tomorrow as a holiday in General Settings. * Confirm the estimate skips that date when counting working days. Scenario 4 - Slowest product: * Create a rule: condition = a product category, processing max +3 days. * Add a normal product and a product in that category to the cart. * Confirm the cart estimate uses the slower (category) product. Scenario 5 - Shipping method changes estimate: * Create a rule for an Express method (transit 1-2) and one for Standard (transit 3-5). * At checkout, switch between the two shipping methods. * Confirm the checkout estimate updates accordingly. Scenario 6 - Frozen estimate: * Place an order and note the estimate. * Change global settings/rules afterwards. * Confirm the thank-you page, email and order meta still show the original estimate. Scenario 7 - HPOS: * Enable WooCommerce High-Performance Order Storage. * Place an order and confirm the `_wpruby_delivery_promise_*` meta is saved on the order. Scenario 8 - WooCommerce inactive: * Deactivate WooCommerce. * Confirm the plugin does not fatal and shows an admin notice. Scenario 9 - Cart & Checkout Blocks: * Use the block-based Cart and Checkout pages (WooCommerce Cart/Checkout blocks). * Confirm the delivery estimate appears in the order summary on both. * Change the shipping method in the block checkout and confirm the estimate updates. == Known Limitations == * Variable products show a single estimate based on the parent/default; per-variation AJAX refresh is not included in V1. * Cart & Checkout Blocks: the estimate renders in the order summary of both blocks via the Store API. Both blocks share the cart/checkout message template and are shown when either the Cart or Checkout display location is enabled. * Shipping zone detection at cart/checkout is best-effort based on the first package. * Rules and settings are stored in options (suitable for typical rule counts). == Changelog == = 1.1.0 = * New: Amazon-style cutoff countdown on the product page ("Order within 9 hrs 41 mins for dispatch today"). It only appears when same-day dispatch is genuinely possible (working day, before cutoff, in stock, zero minimum processing days) and respects matched rules, working days and holidays. * New: Configurable countdown message, expired-cutoff message and "hide after cutoff" option in the Messages tab. * New: Optional vanilla-JS live countdown that updates every 30 seconds using a server-calculated timestamp (timezone-safe) and swaps in the expired message or hides itself at zero. * New: Filters wpruby_delivery_promise_countdown_enabled, wpruby_delivery_promise_countdown_data, wpruby_delivery_promise_same_day_dispatch_available, wpruby_delivery_promise_countdown_message and wpruby_delivery_promise_countdown_expired_message. = 1.0.0 = * Initial release.