Use the term attribute sort order for the "Filter by attribute" block (#47616)
* Use the term attribute sort order for the "Filter by attribute" block * Allow `id` and `name_num` orderby values * Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
7c4ce70916
commit
1d0ec79d43
|
@ -130,7 +130,7 @@ const AttributeFilterBlock = ( {
|
|||
resourceName: 'products/attributes/terms',
|
||||
resourceValues: [ attributeObject?.id || 0 ],
|
||||
shouldSelect: blockAttributes.attributeId > 0,
|
||||
query: { orderby: 'menu_order' },
|
||||
query: { orderby: attributeObject.orderby },
|
||||
} );
|
||||
|
||||
const { results: filteredCounts, isLoading: filteredCountsLoading } =
|
||||
|
|
|
@ -28,6 +28,7 @@ const attributeSettingToObject = ( attribute: AttributeSetting ) => {
|
|||
name: attribute.attribute_name,
|
||||
taxonomy: 'pa_' + attribute.attribute_name,
|
||||
label: attribute.attribute_label,
|
||||
orderby: attribute.attribute_orderby,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
Use the term attribute sort order for displaying the "Filter by attribute" terms.
|
|
@ -63,6 +63,8 @@ class ProductAttributeTerms extends AbstractTermsRoute {
|
|||
public function get_collection_params() {
|
||||
$params = parent::get_collection_params();
|
||||
$params['orderby']['enum'][] = 'menu_order';
|
||||
$params['orderby']['enum'][] = 'name_num';
|
||||
$params['orderby']['enum'][] = 'id';
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@ GET /products/attributes/:id/terms
|
|||
GET /products/attributes/:id/terms?orderby=slug
|
||||
```
|
||||
|
||||
| Attribute | Type | Required | Description |
|
||||
| :-------- | :------ | :------: | :------------------------------------------------------------------------------------------ |
|
||||
| `id` | integer | Yes | The ID of the attribute to retrieve terms for. |
|
||||
| `order` | string | no | Order ascending or descending. Allowed values: `asc`, `desc` |
|
||||
| `orderby` | string | no | Sort collection by object attribute. Allowed values: `name`, `slug`, `count`, `menu_order`. |
|
||||
| Attribute | Type | Required | Description |
|
||||
| :-------- | :------ | :------: |:--------------------------------------------------------------------------------------------------------------|
|
||||
| `id` | integer | Yes | The ID of the attribute to retrieve terms for. |
|
||||
| `order` | string | no | Order ascending or descending. Allowed values: `asc`, `desc` |
|
||||
| `orderby` | string | no | Sort collection by object attribute. Allowed values: `id`, `name`, `name_num`, `slug`, `count`, `menu_order`. |
|
||||
|
||||
```sh
|
||||
curl "https://example-store.com/wp-json/wc/store/v1/products/attributes/1/terms"
|
||||
|
|
Loading…
Reference in New Issue