=== Harbor Equipment Rental for WooCommerce ===
Contributors: harborplugins, freemius
Tags: woocommerce, rental, equipment-rental, booking, date-picker
Requires at least: 6.3
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.0.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 8.0
WC tested up to: 10.9

Let customers pick rental dates, see live pricing, and book available equipment — all inside WooCommerce, no external booking service needed.

== Description ==

**Harbor Equipment Rental for WooCommerce** turns any WooCommerce simple product into a rentable item. Customers pick a date range directly on the product page, and the plugin handles availability, pricing, cart meta, and order tracking — no page builders or external booking services required.

= Free features =

* **Date range picker** — Flatpickr-powered, zero jQuery dependency, works with any theme
* **Per-day pricing** — set a base daily rate; the total updates in real time as the customer selects dates
* **Hourly and weekly rates** — optional hourly and weekly price tiers in addition to the daily rate
* **Availability engine** — automatically blocks dates that are fully booked across confirmed orders; transient-cached and persistent-object-cache aware
* **Cart & checkout** — rental start, end, and day count stored as cart item meta and surfaced on the checkout page
* **Order meta** — rental dates written to each line item via the WooCommerce HPOS-safe API
* **Admin order list** — filter orders by rental date range in WooCommerce > Orders
* **HPOS compatible** — declares compatibility with WooCommerce High-Performance Order Storage

= Pro features =

* **Damage deposit** — a refundable fee added automatically at checkout, configurable per product
* **Availability calendar shortcode** — `[wcrent_calendar product_id="123"]` embeds a read-only calendar anywhere on your site
* **iCal feed** — a secret URL customers can subscribe to in Google Calendar, Apple Calendar, or Outlook
* **Return-reminder email** — automatically emailed N days before the rental end date, fully customisable in WooCommerce > Emails

= Minimum rental period =

Set `_rental_min_days` and `_rental_max_days` on any product to enforce booking window rules. The date picker disables invalid selections and the server re-validates on add-to-cart.

= How it works =

1. Edit any simple product and open the **Rental** tab.
2. Enable rental, set the daily rate, inventory quantity, and optional min/max days.
3. Customers see the date picker on the product page. Unavailable dates are greyed out.
4. On add-to-cart the plugin validates availability server-side and attaches rental dates to the cart item.
5. Order details in WooCommerce admin show the rental dates per line item.

== Installation ==

1. Upload the `harbor-equipment-rental-for-woocommerce` folder to `/wp-content/plugins/`.
2. Activate the plugin through **Plugins > Installed Plugins**.
3. WooCommerce must be active — the plugin will show an admin notice if it is not.
4. Edit any simple product and open the **Rental** tab to configure it.

== Frequently Asked Questions ==

= Does this work with variable products? =

Not in v1.0. Rental is supported on simple products only. Variable product support is planned for a future release.

= Does it support HPOS (High-Performance Order Storage)? =

Yes. The plugin declares full HPOS compatibility and uses `$item->add_meta_data()` throughout — it does not rely on `add_order_item_meta()` or `WP_Query` for order lookups.

= Can I display an availability calendar on the front end? =

A `[wcrent_calendar]` shortcode is included in the Pro plan. The free version greys out unavailable dates directly in the Flatpickr date picker on the product page.

= Where are rental dates stored? =

As line item meta on the WooCommerce order (`_rental_start`, `_rental_end`, `_rental_days`). They are visible in the order detail screen and surfaced in customer emails.

= How is tax applied to rental prices? =

Rental rates follow your store's existing tax settings, exactly like any other WooCommerce product price. Enter your per-day, per-hour, or per-week rates the same way you enter product prices: if **WooCommerce > Settings > Tax** is set to "prices entered inclusive of tax," your rental rates are treated as tax-inclusive; otherwise tax is added on top at checkout. Tax is always calculated against the full rental total (rate multiplied by duration).

= What happens if two customers try to book the same dates? =

Availability is validated server-side at three points: when each customer clicks **Add to cart**, again at checkout (on both the classic and block-based checkout), and a final authoritative check under a database lock at the moment the order is created. If two customers race for the last unit in the same instant, exactly one order succeeds and the other is stopped with an error before any payment is taken — the same equipment can never be double-booked.

This works out of the box on standard single-primary MySQL/MariaDB hosting (virtually all WooCommerce sites). The one-winner guarantee comes from an atomic booking sequence assigned under a database advisory lock that serializes concurrent checkouts: the first order to complete the final check wins, and every later one sees it and is rejected. On multi-writer clusters (Galera, Aurora multi-writer) the advisory lock is not globally coordinated; enable causal reads (e.g. `wsrep_sync_wait`) or route writes to a single primary. The lock timeout and use are adjustable via the `wcrent_booking_lock_timeout` and `wcrent_use_booking_lock` filters.

= Is Flatpickr bundled or loaded from a CDN? =

Bundled locally (`assets/flatpickr.min.js`, v4.6.13, MIT licence). No external requests are made for any booking, pricing, or availability feature.

= Does the plugin send any data externally? =

Booking, order, and customer data never leave your site — every availability and pricing query runs against your own WordPress database. The plugin uses the Freemius SDK for licensing and updates: on activation you are shown a one-time opt-in screen, and if you skip it no diagnostic data is collected. If you opt in, Freemius collects non-personally-identifiable environment data (site URL, WordPress version, PHP version, plugin version) for update delivery and, where applicable, license validation. No order data, customer data, or personally identifiable information is transmitted. See the [Freemius privacy policy](https://freemius.com/privacy/).

== Screenshots ==

1. Product page — date range picker with real-time price summary
2. Cart page — rental dates shown below the product name
3. WooCommerce order detail — rental dates in line item meta
4. Product admin tab — enable rental and configure daily rate

== Support ==

For help, email [support@harborplugins.com](mailto:support@harborplugins.com) or open a thread in the [plugin support forum](https://wordpress.org/support/plugin/harbor-equipment-rental-for-woocommerce/).

== Changelog ==

= 1.0.1 =
* Fix: rental dates now display with readable labels on the admin order screen instead of raw meta keys, and the duplicate raw rows are hidden
* Hardening: fall back to free mode instead of fataling if another plugin's Freemius SDK copy loads first
* Uninstall cleanup query rewritten with prepared identifier placeholders

= 1.0.0 =
* Initial release
* Per-day, hourly, and weekly rental pricing with real-time cart total
* Flatpickr date range picker (v4.6.13, bundled — no CDN, no jQuery)
* Server-side availability engine with transient caching and persistent object cache support
* HPOS-compatible order storage and admin order list filter
* Pro: damage deposit, iCal feed, availability calendar shortcode, return-reminder email

== Upgrade Notice ==

= 1.0.1 =
Admin order screens now show rental dates with readable labels. Recommended for all users.

= 1.0.0 =
Initial release.
