Wp wc product attribute term list
wp wc product_attribute_term_list: Show all terms per taxonomy, with attribute_id
being the ID of a product attribute taxonomy.
$ wp help wc product_attribute_term list NAME wp wc product_attribute_term list DESCRIPTION List all items. SYNOPSIS wp wc product_attribute_term list <attribute_id> [--attribute_id=<attribute_id>] [--context=<context>] [--page=<page>] [--per_page=<per_page>] [--search=<search>] [--exclude=<exclude>] [--include=<include>] [--offset=<offset>] [--order=<order>] [--orderby=<orderby>] [--hide_empty=<hide_empty>] [--parent=<parent>] [--product=<product>] [--slug=<slug>] [--fields=<fields>] [--field=<field>] [--format=<format>] OPTIONS <attribute_id> Attribute ID ← This is the taxonomy id [--attribute_id=<attribute_id>] Unique identifier for the attribute of the terms. [--context=<context>] Scope under which the request is made; determines fields present in response. [--page=<page>] Current page of the collection. [--per_page=<per_page>] Maximum number of items to be returned in result set. [--search=<search>] Limit results to those matching a string. [--exclude=<exclude>] Ensure result set excludes specific IDs. [--include=<include>] Limit result set to specific ids. [--offset=<offset>] Offset the result set by a specific number of items. Applies to hierarchical taxonomies only. [--order=<order>] Order sort attribute ascending or descending. [--orderby=<orderby>] Sort collection by resource attribute. [--hide_empty=<hide_empty>] Whether to hide resources not assigned to any products. [--parent=<parent>] Limit result set to resources assigned to a specific parent. Applies to hierarchical taxonomies only. [--product=<product>] Limit result set to resources assigned to a specific product. [--slug=<slug>] Limit result set to resources with a specific slug. [--fields=<fields>] Limit response to specific fields. Defaults to all fields. [--field=<field>] Get the value of an individual field. [--format=<format>] Render response in a particular format. --- default: table options: - table - json - csv - ids - yaml - count - headers - body - envelope ---
Examples
Only
wp wc product_attribute_term list
Results in an error: A product attribute taxonomy ID is compulsory.
Let's first retrieve product attribute taxonomy IDs:
$ wp --user=4 wc product_attribute list +----+-----------------------+--------------------------+--------+------------+--------------+ | id | name | slug | type | order_by | has_archives | +----+-----------------------+--------------------------+--------+------------+--------------+ | 16 | As-code | pa_as_code | select | menu_order | 1 | | 17 | Stop? | pa_automatische_stop | select | menu_order | 1 | | 18 | Breedte (mm) | pa_breedte | text | menu_order | 1 | | 19 | Connector? | pa_connector | select | menu_order | 1 | | 20 | Diagram | pa_diagram | text | menu_order | 1 | | 21 | Diepte (mm) | pa_diepte | text | menu_order | 1 | | 22 | Lengte (mm) | pa_lengte | text | menu_order | 1 | | 23 | Originele Widget | pa_originele_widget | select | menu_order | 1 | | 24 | Stroomdraad? | pa_stroomdraad | select | menu_order | 1 | | 25 | Model | pa_model | select | menu_order | 1 | | 26 | Submodel | pa_submodel | select | menu_order | 1 | | 27 | Veer? | pa_veer | select | menu_order | 1 | | 28 | Productlijn | pa_productlijn | select | menu_order | 1 | | 29 | Apparaat | pa_apparaat | select | menu_order | 1 | | 30 | Materiaal | pa_materiaal | select | name | 1 | | 31 | Zoeken-op-afbeelding | pa_zoeken-op-afbeelding | select | menu_order | 1 | +----+-----------------------+--------------------------+--------+------------+--------------+
with user 4
being my own user id with admin privileges.
Now that we figured out that e.g., 29 is the id of a product attribute taxonomy:
wp wc product_attribute_term list 29 --user=4 +-------+------------------+------------------+---------------------------------+------------+-------+ | id | name | slug | description | menu_order | count | +-------+------------------+------------------+---------------------------------+------------+-------+ | 45244 | Alternator | alternator | Alle widgets voor alternators | 0 | 12 | | 34601 | Blazer | blazer | Alle widgers voor Blazer | 0 | 26 | | 45246 | Boorhamer | boorhamer | Alle widgets voor boorhamers | 0 | 0 | | 34582 | Boormachine | boormachine | Alle widgets - Boormachine | 0 | 2929 | +-------+------------------+------------------+---------------------------------+------------+-------+
Multiple attribute-ids?
The syntaxis seems to suggest two attribute-id related arguments. I have the impression that they are the same or so:
wp --user=4 wc product_attribute_term list 20 wp --user=4 wc product_attribute_term list --attribute_id=20 # Error wp --user=4 wc product_attribute_term list 20 --attribute_id=20 wp --user=4 wc product_attribute_term list 12 --attribute_id=20 # Uses "20" as argument
Return just one term?
How to get info about just one term, specified by id? This works, but is inefficient and probably error-prone:
$ wp --user=4 wc product_attribute_term list 20 --fields=id,name | grep 20307 20307 523
The real answer, is to use wp wc product_attribute_term get