> ## Documentation Index
> Fetch the complete documentation index at: https://docs.smartwpplugins.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Classic Checkout

> How Unwan integrates with the shortcode-based checkout

Stores still using the classic, shortcode-based `[woocommerce_checkout]` page get the identical picker — same markup, same JavaScript controller, same labels — through a separate adapter built on classic checkout's own hooks.

## How it mounts

Unwan prints an empty mount point immediately before WooCommerce's native billing and shipping forms:

```php theme={null}
// via woocommerce_before_checkout_billing_form / _shipping_form
<div class="unwan-checkout__selector" data-unwan-address-type="billing"></div>
```

The classic-checkout JavaScript (`unwan-classic-checkout.js`) reads a localized `window.unwanClassicCheckout` object — containing each customer's checkout options, field keys, labels, and search threshold — and mounts the same shared controller used by Checkout Blocks (`window.unwanAddressPicker`, documented in the [JavaScript API](https://docs.smartwpplugins.com/unwan/developers/javascript-api.md)) into each placeholder.

## Submission and validation

Unwan adds a hidden field per enabled selector (`unwan_billing_address_id` / `unwan_shipping_address_id`) holding the current selection. The script writes it again just before the order is submitted, and creates it if a checkout template left it out. On submit:

1. `woocommerce_after_checkout_validation` rejects the order only if a submitted value is a saved-address ID that isn't in that customer's address book — the same server-side check a crafted or stale request would need to defeat. An empty value means "no selection", not an invalid one: checkout builders that print only their own fields never post it, and other scripts can blank it, so such orders go through normally.
2. `woocommerce_checkout_update_customer` puts the customer's stored billing and shipping defaults back on the customer object just before WooCommerce saves it, when the picker posted a selection. Everything else WooCommerce saves as usual — a changed billing email, custom fields from checkout field editors, and other plugins' data. A type whose default is still empty is left for WooCommerce to fill.
3. `woocommerce_checkout_update_user_meta` saves a new address (if `"new"` was chosen, the address has a street, city or postcode, and **Save checkout addresses** is on) and, if configured, promotes it to the matching profile default — even when the additional-address limit is full.

## Fields that stay visible

A selected saved address collapses the standard address rows, never the whole form, so fields other plugins add stay where they are. A row is shown again when:

* WooCommerce or a field editor marks it required for the address's country and the saved address has no value for it. Unwan works out the required fields for the store's country and every country in the customer's address book, because WooCommerce's own country rules change the required markers on the page as the form loads.
* WooCommerce marks it invalid.
* The order is refused because of it. WooCommerce names the field in its error message (for example an invalid postcode), and Unwan reopens that row so the customer can correct it.

## Detecting Checkout Blocks pages

The classic-checkout script only enqueues on pages that are actually running the shortcode checkout. Unwan checks whether the current queried page contains the `woocommerce/checkout` block and skips its own classic assets if so, so the two adapters never both try to mount on the same page.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.