=== SPP Conditional Checkout Fields ===
Contributors: simpliplugin
Tags: woocommerce, checkout, conditional fields, checkout fields, billing
Requires at least: 5.6
Tested up to: 7.0
Requires PHP: 7.2
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Show, hide or require WooCommerce billing & shipping checkout fields based on cart items, product categories or user roles.

== Description ==

**SPP Conditional Checkout Fields** lets you control which WooCommerce checkout
fields appear for each customer. Build simple rules that show, hide, require or
make optional any billing or shipping field depending on what is in the cart or
who the customer is.

Common use cases:

* Hide shipping fields for virtual/downloadable-only carts.
* Require the "Company" field only for wholesale (custom role) customers.
* Show an extra address field only when a specific product or category is in the cart.
* Make the phone field optional for logged-in customers.

= Key features =

* Unlimited rules with a friendly, no-code editor.
* Conditions based on: cart contains product, cart contains product category,
  user role, cart subtotal, and cart item count.
* Match **any** (OR) or **all** (AND) of a rule's conditions.
* Actions: hide fields, show fields only when matched, make required, or make optional.
* Works with standard WooCommerce billing and shipping fields.
* Developer friendly: filters to add custom fields, conditions and context.
* Translation ready and compatible with WooCommerce High-Performance Order Storage (HPOS).

= Developer hooks =

* `spp_ccf_targetable_fields` – add/modify the fields that rules can target.
* `spp_ccf_condition_matches` – evaluate custom condition types.
* `spp_ccf_context` – modify the cart/user context used for evaluation.
* `spp_ccf_resolved_field_actions` – adjust the final per-field actions.

== Installation ==

1. Upload the `spp-conditional-checkout-fields` folder to `/wp-content/plugins/`,
   or install it from the Plugins screen in WordPress.
2. Activate the plugin through the **Plugins** menu.
3. Go to **WooCommerce > Conditional Fields** to create your rules.

WooCommerce must be installed and active.

== Frequently Asked Questions ==

= Does this work with the block-based checkout? =

Yes. The classic (shortcode) checkout is handled server-side via the standard
WooCommerce checkout fields API. The block checkout is handled via the address
field APIs WooCommerce provides for blocks (woocommerce_get_country_locale and
woocommerce_default_address_fields), plus a small safety-net script.

Please note: the block checkout shares a single address field configuration
between the billing and shipping sections, so on the block checkout a rule that
targets, for example, "Billing Company" also affects "Shipping Company". The
classic checkout remains fully per-section. The contact "Email" field is not an
address field, so it can only be targeted on the classic checkout.

= Will hidden required fields block the order? =

No. When a field is hidden it is fully removed from the checkout, so WooCommerce
does not validate it.

= Can I target custom checkout fields? =

Yes. Use the `spp_ccf_targetable_fields` filter to register additional fields so
they appear in the rule editor.

== Screenshots ==

1. The rule editor under WooCommerce > Conditional Fields.
2. A rule hiding shipping fields for a specific user role.

== Changelog ==

= 1.0.1 =
* Added: WooCommerce block checkout support via the supported address field APIs (woocommerce_get_country_locale, woocommerce_get_country_locale_default and woocommerce_default_address_fields), so hide/show/required/optional now work on both classic and block checkout.
* Changed: the "Show" action is now a whitelist - "Show only the selected fields (hide all other fields)" - which hides every other field in the affected billing/shipping group(s).
* Fixed: "required" and "optional" actions had no effect on the block checkout because the default locale was not updated (per WooCommerce developer advisory).
* Fixed: rule context could be evaluated before the cart was loaded on some requests.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
