Wp wc product list
Versie door Jeroen Strompf (overleg | bijdragen) op 30 sep 2022 om 13:53 (→Number of returned rows)
$wp wc product list NAME wp wc product list DESCRIPTION List all items. SYNOPSIS wp wc product list [--context=<context>] [--page=<page>] [--per_page=<per_page>] [--search=<search>] [--after=<after>] [--before=<before>] [--dates_are_gmt=<dates_are_gmt>] [--exclude=<exclude>] [--include=<include>] [--offset=<offset>] [--order=<order>] [--orderby=<orderby>] [--parent=<parent>] [--parent_exclude=<parent_exclude>] [--slug=<slug>] [--status=<status>] [--type=<type>] [--sku=<sku>] [--featured=<featured>] [--category=<category>] [--tag=<tag>] [--shipping_class=<shipping_class>] [--attribute=<attribute>] [--attribute_term=<attribute_term>] [--tax_class=<tax_class>] [--in_stock=<in_stock>] [--on_sale=<on_sale>] [--min_price=<min_price>] [--max_price=<max_price>] [--fields=<fields>] [--field=<field>] [--format=<format>] OPTIONS [--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. [--after=<after>] Limit response to resources published after a given ISO8601 compliant date. [--before=<before>] Limit response to resources published before a given ISO8601 compliant date. [--dates_are_gmt=<dates_are_gmt>] Whether to use GMT post dates. [--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. [--order=<order>] Order sort attribute ascending or descending. [--orderby=<orderby>] Sort collection by object attribute. [--parent=<parent>] Limit result set to those of particular parent IDs. [--parent_exclude=<parent_exclude>] Limit result set to all items except those of a particular parent ID. [--slug=<slug>] Limit result set to products with a specific slug. [--status=<status>] Limit result set to products assigned a specific status. [--type=<type>] Limit result set to products assigned a specific type. [--sku=<sku>] Limit result set to products with specific SKU(s). Use commas to separate. [--featured=<featured>] Limit result set to featured products. [--category=<category>] Limit result set to products assigned a specific category ID. [--tag=<tag>] Limit result set to products assigned a specific tag ID. [--shipping_class=<shipping_class>] Limit result set to products assigned a specific shipping class ID. [--attribute=<attribute>] Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug. [--attribute_term=<attribute_term>] Limit result set to products with a specific attribute term ID (required an assigned attribute). [--tax_class=<tax_class>] Limit result set to products with a specific tax class. [--in_stock=<in_stock>] Limit result set to products in stock or out of stock. [--on_sale=<on_sale>] Limit result set to products on sale. [--min_price=<min_price>] Limit result set to products based on a minimum price. [--max_price=<max_price>] Limit result set to products based on a maximum price. [--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 ---
Fields
On Aug. 2, 2021 I got the output of no less than 65 fields. Some of these are presumably custom work and sometimes the output was serialised:
|
|
|
Examples
wp --user=4 wc product list # Too much information? wp --user=4 wc product list --field=id # Too little information? wp --user=4 wc product list --fields=id,name # Useful!
Number of returned rows
By default, 100 rows are returned. This is also the maximum value:
wp --user=4 wc product list --field=id --per_page=200 Unable to open /var/www/example.com/wp-content/wflogs/config.php for reading and writing. Error: Invalid parameter(s): per_page {"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"},"details":{"per_page": {"code":"rest_out_of_bounds","message":"per_page must be between 1 (inclusive) and 100 (inclusive)","data":null}}}