=== Okuricart ===
Contributors: tshuto
Tags: woocommerce, japan, checkout, furigana, postal-code
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 8.9
WC tested up to: 11.2

Japanese-style WooCommerce checkout: furigana, postal code autofill, input memory, free-shipping bar, noshi and delivery date/time.

== Description ==

Okuricart extends WooCommerce for Japanese online stores (especially gift and food shops) with Japan-specific checkout features. The free version provides a reliable, well-designed "Japanese-style checkout".

* Furigana (kana reading) fields, placed right after the name, auto-generated from the kanji as the customer types and fully editable
* Postal code to address autofill (uses the postal code data stored on your site, with an optional external API fallback)
* One-click import of Japan Post's nationwide postal code data from the settings screen, with an optional monthly automatic update
* Remember input for next time (stored on this device only, no account required, opt-in, off by default)
* Free-shipping bar ("あと¥○で送料無料" / "¥X more for free shipping") on the cart and checkout, using the free shipping threshold already set in your WooCommerce shipping zones
* Noshi (gift label) request at checkout: a "のしを希望する" checkbox and a free-text field for the label wording, shown on the order screen, emails and order details
* Delivery date and time slot request at checkout: the customer picks from dates built from your settings (lead time, selectable window, closed weekdays and specific closed dates), so holidays never appear as options
* Block checkout (Cart & Checkout Blocks) and classic (shortcode) checkout support, HPOS compatible

The premium version (sold separately) will add a shipping rate engine (carrier rates and estimated delivery dates), full noshi support (wording/mizuhiki rules, vertical preview, per-line labels), multiple shipping destinations, invoice documents, and repeat ordering.

== Installation ==

1. Install and activate the plugin (WooCommerce is required).
2. The Japanese-style fields work on both the block (Cart & Checkout Blocks) and the classic (shortcode) checkout.
3. Configure postal code autofill (including the nationwide data import), input memory, furigana, the free-shipping bar, noshi requests, delivery date/time, and data removal under WooCommerce > Settings > Okuricart.

== Frequently Asked Questions ==

= Is WooCommerce required? =
Yes. This plugin extends WooCommerce.

= Does the input memory feature send personal data anywhere? =
No. Input memory is stored only in the customer's browser (localStorage) and is never sent to the server or saved to the order. It is opt-in and off by default, the consent checkbox is always unchecked, and payment details and email address are never stored. Saved data is removed after the retention period you set (30 to 90 days).

= Does it work with both block and classic checkout? =
Yes. The Japanese-style fields (furigana, postal code autofill, input memory, free-shipping bar, noshi request) work on both the Cart & Checkout Blocks and the classic shortcode checkout.

= How is the furigana (kana reading) generated? =
As the customer types their name in kanji, the reading typed before IME conversion is captured on the device and filled into the furigana fields as katakana. No dictionary or external service is used, and the customer can edit the furigana. This can be turned off under WooCommerce > Settings > Okuricart.

= What happens to my data when I uninstall the plugin? =
By default nothing is deleted, so your data is kept if you reinstall. If you enable "delete data on uninstall" under WooCommerce > Settings > Okuricart, the plugin's tables and settings are removed when the plugin is deleted.

= Where does the free-shipping bar get its threshold? =
From WooCommerce itself. Add a "Free shipping" method to your shipping zone with a minimum order amount, and the bar shows how much more the customer needs to spend, matching WooCommerce's own free-shipping decision (including coupons and tax display). If no such method exists in the zone, nothing is shown. The bar can be turned off under WooCommerce > Settings > Okuricart.

= What does the noshi request do? =
It adds a "のしを希望する" (request a noshi gift label) checkbox and a free-text field (up to 200 characters) for the label wording to the checkout. The request is saved with the order and shown on the order screen, in order emails and in the customer's order details. It can be turned off for non-gift stores under WooCommerce > Settings > Okuricart. Automatic wording/mizuhiki rules, vertical preview and per-line labels are part of the premium version.

= How do I load the nationwide postal code data? =
The plugin ships with only a small sample of postal codes (16 entries) for testing. Until the full data is loaded, any postal code not found on your site is looked up via the zipcloud external API (see "External services" below).

The easiest way is the built-in importer: go to WooCommerce > Settings > Okuricart and click "全国データを取り込む" (Import nationwide data). It downloads Japan Post's data and imports it in the background (about 120,000 entries), so lookups keep working while it runs. A once-a-month automatic update is on by default and can be turned off there.

Alternatively, with WP-CLI:

1. Download "utf_ken_all.zip" from Japan Post (https://www.post.japanpost.jp/zipcode/download.html) and unzip it to get "utf_ken_all.csv".
2. Place the CSV on your server (for example under the plugin's data/private/ directory).
3. Run: `wp okuricart postal-code import path/to/utf_ken_all.csv` (add `--no-truncate` to append instead of replacing existing data).

After importing, you can turn off the external API fallback under WooCommerce > Settings > Okuricart ("外部APIでの補完").

== Screenshots ==

1. Japanese-style block checkout: furigana fields placed right after the name, with the postal code automatically filling prefecture, city, and town.
2. The opt-in "remember input on this device" checkbox at checkout (off by default).
3. Furigana carried through to the order confirmation page after checkout.
4. The Okuricart settings screen under WooCommerce > Settings.
5. The free-shipping bar ("¥3,000 more for free shipping") in the order summary and the noshi (gift label) request fields under "Additional order information" on the block checkout.

== External services ==

This plugin can connect to the zipcloud postal code API (https://zipcloud.ibsnet.co.jp/) to look up an address when the entered postal code is not found in the postal code data stored on your site.

* What is sent: only the 7-digit postal code the customer entered at checkout (no name, address, or other personal data).
* When: only when the postal code is not found in the site's own postal code data. This can be turned off under WooCommerce > Settings > Okuricart ("外部APIでの補完").
* zipcloud terms of use: https://zipcloud.ibsnet.co.jp/rule/api

This plugin can download the nationwide postal code data file from Japan Post (https://www.post.japanpost.jp/) to fill the on-site postal code database.

* What is sent: a plain HTTP GET request for the public data file (utf_ken_all.zip). No personal data or site information is sent.
* When: only when you click "全国データを取り込む" under WooCommerce > Settings > Okuricart, and (if "月次自動更新" is on) once a month in the background. Japan Post's site terms: https://www.post.japanpost.jp/zipcode/dl/readme.html

== Changelog ==

= 0.4.0 =
* New: delivery date and time slot request at checkout (block and classic). Selectable dates are built from your settings — lead time, selectable window, closed weekdays and specific closed dates (holidays) — so closed days never appear as options. Shown on the admin order screen, order emails, order details and the Analytics order export.
* Improved: the noshi request now appears as columns in the Analytics > Orders export, and noshi in order emails is rendered through WooCommerce's own order-meta styling.
* Developers: public hooks for the premium add-on (okuricart_loaded, okuricart_settings_sections, okuricart_settings_tabs, okuricart_checkout_field_registered) and a jpcart_shipping_group row created per order. The free version stays fully functional on its own.
* Note: the Freemius SDK is not bundled in the free version.

= 0.2.0 =
* New: import Japan Post's nationwide postal code data from WooCommerce > Settings > Okuricart (background job, atomic table swap), with an optional monthly automatic update.
* New: free-shipping bar "あと¥○で送料無料" on the cart and checkout (block and classic), driven by the free shipping threshold of the matching WooCommerce shipping zone.
* New: noshi (gift label) request at checkout (block and classic): checkbox plus free-text wording, shown on the admin order screen, order emails and order details.
* Note: the Freemius SDK is not bundled in the free version.

= 0.1.0 =
* Initial release: Japanese-style checkout (furigana with auto-generation, postal code to address autofill, input memory), for both block and classic checkout.

== Upgrade Notice ==

= 0.4.0 =
Adds a delivery date/time request at checkout with holiday (closed-day) settings. No data migration is needed; the feature is on by default and can be turned off under WooCommerce > Settings > Okuricart.

= 0.2.0 =
Adds the nationwide postal code importer, the free-shipping bar and noshi requests. No data migration is needed; new features are on by default and can be turned off under WooCommerce > Settings > Okuricart.

= 0.1.0 =
Initial release.
