Update additional fields document's TOC and link to it from another document. (#47137)
* update docs * Add changefile(s) from automation for the following project(s): woocommerce-blocks * fix linting * update manifest --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
b5850bbfc1
commit
ccba86a616
|
@ -7,6 +7,10 @@ If you are unfamiliar with code and resolving potential conflicts, we have an ex
|
|||
|
||||
Custom code should be copied into your child theme's **functions.php** file.
|
||||
|
||||
## Note
|
||||
|
||||
Some parts of this document only applies to the shortcode Checkout, for adding fields to the Checkout block, [consult this document.](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce-blocks/docs/third-party-developers/extensibility/checkout-block/additional-checkout-fields.md)
|
||||
|
||||
## How Are Checkout Fields Loaded to WooCommerce?
|
||||
|
||||
The billing and shipping fields for checkout pull from the countries class `class-wc-countries.php` and the **`get_address_fields`** function. This allows WooCommerce to enable/disable fields based on the user's location.
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
"post_title": "Customizing checkout fields using actions and filters",
|
||||
"tags": "code-snippet",
|
||||
"edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/code-snippets/customising-checkout-fields.md",
|
||||
"hash": "95cdfe40544c35e1918a56654d3fe2c42490b3b91ac10713cc1c005baa003686",
|
||||
"hash": "3b0ce072c92206279fc6d49f3aa4cb0e4fbc2da71a2a5f0ffada81c030c397df",
|
||||
"url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/code-snippets/customising-checkout-fields.md",
|
||||
"id": "83097d3b7414557fc80dcf9f8f1a708bbdcdd884"
|
||||
},
|
||||
|
@ -1266,5 +1266,5 @@
|
|||
"categories": []
|
||||
}
|
||||
],
|
||||
"hash": "24c95fd5e28dc3e1fd03ffa495e1487bafc1dc8c3ffa91334f05ac2ea3b12e78"
|
||||
"hash": "556bb0eab0e99ed385dbc32b96008add0b64f01888d4aae6f7051345aae045cc"
|
||||
}
|
|
@ -6,12 +6,20 @@
|
|||
- [Contact information](#contact-information)
|
||||
- [Address](#address)
|
||||
- [Order information](#order-information)
|
||||
- [Accessing values](#accessing-values)
|
||||
- [Helper methods](#helper-methods)
|
||||
- [Guest customers](#guest-customers)
|
||||
- [Logged-in customers](#logged-in-customers)
|
||||
- [Accessing all fields](#accessing-all-fields)
|
||||
- [Accessing values directly](#accessing-values-directly)
|
||||
- [Checkboxes values](#checkboxes-values)
|
||||
- [Supported field types](#supported-field-types)
|
||||
- [Using the API](#using-the-api)
|
||||
- [Options](#options)
|
||||
- [General options](#general-options)
|
||||
- [Options for `text` fields](#options-for-text-fields)
|
||||
- [Options for `select` fields](#options-for-select-fields)
|
||||
- [Example of `options` value](#example-of-options-value)
|
||||
- [Options for `checkbox` fields](#options-for-checkbox-fields)
|
||||
- [Attributes](#attributes)
|
||||
- [Usage examples](#usage-examples)
|
||||
|
@ -249,7 +257,7 @@ These options apply to all field types (except in a few circumstances which are
|
|||
| `sanitize_callback` | A function called to sanitize the customer provided value when posted. | No | See example below | By default the field's value is returned unchanged. |
|
||||
| `validate_callback` | A function called to validate the customer provided value when posted. This runs _after_ sanitization. | No | See example below | The default validation function will add an error to the response if the field is required and does not have a value. [See the default validation function.](https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFields.php#L270-L281) |
|
||||
|
||||
##### * Example of `sanitize_callback`. This function will remove spaces from the value
|
||||
##### Example of `sanitize_callback`. This function will remove spaces from the value <!-- omit from toc -->
|
||||
|
||||
```php
|
||||
'sanitize_callback' => function( $field_value ) {
|
||||
|
@ -257,7 +265,7 @@ These options apply to all field types (except in a few circumstances which are
|
|||
},
|
||||
```
|
||||
|
||||
##### * Example of `validate_callback`. This function will check if the value is an email
|
||||
##### Example of `validate_callback`. This function will check if the value is an email <!-- omit from toc -->
|
||||
|
||||
```php
|
||||
'validate_callback' => function( $field_value ) {
|
||||
|
@ -283,10 +291,10 @@ Select fields can also be marked as required. If they are not (i.e. they are opt
|
|||
|
||||
| Option name | Description | Required? | Example | Default value |
|
||||
|-----|-----|-----|----------------|--------------|
|
||||
| `options` | An array of options to show in the select input. Each options must be an array containing a `label` and `value` property. Each entry must have a unique `value`. Any duplicate options will be removed. The `value` is what gets submitted to the server during checkout and the `label` is simply a user-friendly representation of this value. It is not transmitted to the server in any way. | Yes | *see below | No default - this must be provided. |
|
||||
| `options` | An array of options to show in the select input. Each options must be an array containing a `label` and `value` property. Each entry must have a unique `value`. Any duplicate options will be removed. The `value` is what gets submitted to the server during checkout and the `label` is simply a user-friendly representation of this value. It is not transmitted to the server in any way. | Yes | see below | No default - this must be provided. |
|
||||
| `required` | If this is `true` then the shopper _must_ provide a value for this field during the checkout process. | No | `true` | `false` |
|
||||
|
||||
##### *Example of `options` value
|
||||
##### Example of `options` value
|
||||
|
||||
```php
|
||||
[
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: tweak
|
||||
Comment: Update docs TOC.
|
||||
|
Loading…
Reference in New Issue