=== Delivery Date Cutoff Estimator ===
Contributors: starlink1207
Tags: delivery date, estimated delivery, shipping, woocommerce, cutoff
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show "order now, get it by" delivery dates on WooCommerce product pages and cart, with a same-day dispatch cutoff and closed days.

== Description ==

Customers buy faster when they know when the parcel arrives. Delivery Date Cutoff Estimator calculates a realistic delivery window from your own dispatch routine and shows it where buying decisions happen.

= Why stores choose it =

* **A free version that actually works.** Same-day cutoff, dispatch and delivery days, product, cart and checkout display and the promised date saved on every order – all free, with no product or order limits.
* **Block cart/checkout and HPOS support.** Works with the block cart and checkout, block themes and WooCommerce custom order tables.
* **Never blocks checkout.** There is no required date field and no date picker that can stop an order – it only informs.
* **Cache-safe dates.** Pages served from a full-page cache or CDN refresh the date after loading, so customers never see yesterday's promise.

= Free features =

* Same-day dispatch cutoff time (in your site timezone).
* Handling time and default transit time (min–max working days).
* Dispatch days and carrier delivery days – weekends and closed days are skipped automatically.
* Estimate on single product pages (classic and block themes).
* Estimate row in the cart and checkout totals (classic and block cart/checkout).
* Optional compact "Get it by {date_max}" line on shop, category and product list blocks.
* Per-product extra handling days (made to order, pre-order) and a per-product "hide" switch.
* Stock-aware lead time: extra handling days when a product is on backorder or out of stock, or when the quantity in the cart is higher than your stock.
* Cache-proof dates: the server-calculated date is shown first and then refreshed after page load through a small read-only endpoint on your own site (can be switched off).
* Looks native in any theme: inherits your fonts and text colour, uses your theme palette, readable on dark themes, RTL-ready. Optional text, background and border colours and an on/off truck icon.
* The promised date is stored on every order and shown on the order admin screen, order received page and My Account.
* Editable texts with placeholders: {date_range}, {date_min}, {date_max}, {ship_date}, {ship_day}.
* Shortcode `[pmw1tdcnd_estimate]` or `[pmw1tdcnd_estimate product_id="123"]` for any page.
* Live preview in the settings screen: "if a customer orders right now".
* HPOS (custom order tables) compatible.

The plugin does not contact any external service. Scripts and styles load only on pages that actually show an estimate.

Delivery Date Cutoff Estimator Pro adds transit times per WooCommerce shipping zone and shipping method, extra handling days and transit times per shipping class and product category (the slowest product decides in the cart), per-variation handling days with a live estimate when a customer picks a variation, a delivery date under each shipping method in the classic cart and checkout, a holiday calendar with one-off and yearly closed dates, the estimated delivery date in WooCommerce order emails, and a live cutoff countdown ("Order within 2h 15m to ship today"). Upgrade from the Delivery Estimates settings screen.

== Installation ==

1. Install and activate WooCommerce.
2. Upload the plugin folder to `/wp-content/plugins/` or install it from the Plugins screen, then activate it.
3. Go to WooCommerce → Delivery Estimates.
4. Set your cutoff time, handling time, transit days and dispatch days. Check the live preview and save.

== Frequently Asked Questions ==

= Which timezone is used for the cutoff? =

The timezone set under Settings → General. The settings screen shows the current site time so you can double-check.

= How is the date calculated? =

Orders placed before the cutoff on a dispatch day count for that day; later orders count for the next dispatch day. Handling days are added on dispatch days, then transit days are added on carrier delivery days. Holidays (Pro) are skipped in both steps.

= Can one product take longer than others? =

Yes. Edit the product, open the Shipping tab and set "Extra handling days". In the cart the slowest product decides the date.

= What happens with backorders? =

Set "Extra handling days for backorders / out-of-stock items" under Dispatch & transit. The extra days are added when a product is on backorder or out of stock (if you show the estimate for out-of-stock products), and in the cart when the quantity is higher than the stock you have.

= Does it work with the block cart and checkout? =

Yes. The estimate is shown above the cart and checkout blocks, and saved to orders placed through the block checkout. The Pro delivery date under each shipping method is shown in the classic cart and checkout only; the block checkout keeps the single estimate above the checkout.

= I use a page cache. Is the date still correct? =

Yes. With "Refresh dates after page load (for cached sites)" switched on (the default), the page first shows the date calculated when the page was cached, then a tiny script asks your own site for the current date and updates the text – so a full-page cache or CDN never shows a stale date or an expired countdown. The endpoint is read-only, sends no-cache headers and only returns the text a visitor would see anyway. If JavaScript is off, the cached date is shown.

= Can I show the date on shop and category pages? =

Yes. Enable "Product lists" under Shop & category pages. It adds a compact "Get it by …" line under the price in classic shop loops and in product collection blocks.

= Will it match my theme? =

The box inherits your theme's fonts and text colour, uses a light tint of the text colour as background and your theme's main colour for the edge and icon, so it works on light and dark themes. You can set your own colours or hide the icon under Style.

= Will uninstalling delete my data? =

Deleting the plugin removes its settings, holidays, rules and product settings. Dates already stored on orders are kept so your order history stays accurate.

== Screenshots ==

1. Delivery estimate on the product page.
2. Settings with a live "if a customer orders right now" preview.

== Changelog ==

= 1.0.3 =
* New: cache-proof dates – estimates refresh after page load through a small read-only endpoint, so cached pages never show a stale date (on by default).
* New: extra handling days for backorders, out-of-stock items and cart quantities above stock.
* New: optional "Get it by" line on shop, category and product list blocks.
* New: text, background and border colour settings and an icon on/off switch.
* Improved: storefront styles follow the theme (fonts, colours, dark themes, RTL, mobile) with an inline SVG icon.
* Improved: scripts load deferred in the footer and only where an estimate is shown.
* Pro: rules by shipping class and product category, per-variation handling days with live updates, and a delivery date under each shipping method in the classic cart and checkout.

= 1.0.2 =
* Hardened output escaping, input sanitizing and database queries.
* 14-day free trial of Pro from the plugin screen.

= 1.0.1 =
* Cleaner admin menu (no separate Contact Us item).

= 1.0.0 =
* First release.
