Add block documentation to woocommerce/product-checkbox-field (#40277)

* Rename block description

* Add documentation for product checkbox field

* Add changelog

* Improve README

* Add description to block's attributes

* Replace example

* Add markdown table with documentation

* Move image to developer.woocommerce.com

* Iterate documentation

* Address lints
This commit is contained in:
Nathan Silveira 2023-09-27 15:07:52 -03:00 committed by GitHub
parent 88ead8f672
commit 8edcb06348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: enhancement
Comment: Add documentation for woocommerce/product-checkbox-field

View File

@ -0,0 +1,67 @@
# woocommerce/product-checkbox-field
A reusable checkbox for the product editor.
![Product checkbox field screenshot](https://woocommerce.files.wordpress.com/2023/09/checkbox.png)
_Please note that to persist a custom field in the product it also needs to be added to the WooCommerce REST API._
## Attributes
### title
- **Type:** `String`
- **Required:** `No`
Header that appears above the checkbox.
### label
- **Type:** `String`
- **Required:** `No`
Label that appears at the side of the checkbox.
### property
- **Type:** `String`
- **Required:** `Yes`
Property in which the checkbox value is stored.
### tooltip
- **Type:** `String`
- **Required:** `No`
Tooltip text that is shown when hovering the icon at the side of the label.
## Example
Here's an example on the code that is used for the 'sold_individually' field in the Inventory section:
```php
$parent_container->add_block(
[
'id' => 'product-limit-purchase',
'blockName' => 'woocommerce/product-checkbox-field',
'order' => 20,
'attributes' => [
'title' => __(
'Restrictions',
'woocommerce'
),
'label' => __(
'Limit purchases to 1 item per order',
'woocommerce'
),
'property' => 'sold_individually',
'tooltip' => __(
'When checked, customers will be able to purchase only 1 item in a single order. This is particularly useful for items that have limited quantity, like art or handmade goods.',
'woocommerce'
),
],
]
);
```

View File

@ -4,7 +4,7 @@
"name": "woocommerce/product-checkbox-field", "name": "woocommerce/product-checkbox-field",
"title": "Product checkbox control", "title": "Product checkbox control",
"category": "woocommerce", "category": "woocommerce",
"description": "The product checkbox.", "description": "A reusable checkbox for the product editor.",
"keywords": [ "products", "checkbox", "input" ], "keywords": [ "products", "checkbox", "input" ],
"textdomain": "default", "textdomain": "default",
"attributes": { "attributes": {