跳到主要内容
将当前页面内容以 Markdown 格式复制到剪贴板

设置选项

Setting option properties

AttributeTypeDescription
idstringA unique identifier for the setting. READ-ONLY
labelstringA human readable label for the setting used in interfaces. READ-ONLY
descriptionstringA human readable description for the setting used in interfaces. READ-ONLY
valuemixedSetting value.
defaultmixedDefault value for the setting. READ-ONLY
tipstringAdditional help text shown to the user about the setting. READ-ONLY
placeholderstringPlaceholder text to be displayed in text inputs. READ-ONLY
typestringType of setting. Options: text, email, number, color, password, textarea, select, multiselect, radio, image_width and checkbox. READ-ONLY
optionsobjectArray of options (key value pairs) for inputs such as select, multiselect, and radio buttons. READ-ONLY
group_idstringAn identifier for the group this setting belongs to. READ-ONLY

Retrieve a setting option

This API lets you retrieve and view a specific setting option.

GET /wp-json/wc/v3/settings/<group_id>/<id>
curl https://example.com/wp-json/wc/v3/settings/general/woocommerce_allowed_countries \
-u consumer_key:consumer_secret

列出所有设置选项

此 API 可以帮助您查看所有设置选项。

GET /wp-json/wc/v3/settings/<id>
curl https://example.com/wp-json/wc/v3/settings/general \
-u consumer_key:consumer_secret

更新一个设置选项

这个 API 允许您对一个设置选项进行更改。

PUT /wp-json/wc/v3/settings/<group_id>/<id>
curl -X PUT https://example.com/wp-json/wc/v3/settings/general/woocommerce_allowed_countries \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"value": "all_except"
}'

批量更新设置选项

此 API 可帮助您批量更新多个设置选项。

备注

注意:默认情况下,创建、更新或删除的对象数量限制为最多 100 个。

POST /wp-json/wc/v3/settings/<id>/batch
curl -X POST https://example.com/wp-json/wc/v3/settings/general/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"update": [
{
"id": "woocommerce_allowed_countries",
"value": "all"
},
{
"id": "woocommerce_demo_store",
"value": "yes"
},
{
"id": "woocommerce_currency",
"value": "GBP"
}
]
}'