Skip to main content

Product shipping classes

The product shipping class API allows you to create, view, update, and delete individual, or a batch, of shipping classes.

Product shipping class properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
namestringShipping class name. MANDATORY
slugstringAn alphanumeric identifier for the resource unique to its type.
descriptionstringHTML description of the resource.
countintegerNumber of published products for the resource. READ-ONLY

Create a shipping class

This API helps you to create a new product shipping class.

POST /wp-json/wc/v2/products/shipping_classes

Example of how to create a product shipping class:

curl -X POST https://example.com/wp-json/wc/v2/products/shipping_classes \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Priority"
}'

Retrieve a shipping class

This API lets you retrieve a product shipping class by ID.

GET /wp-json/wc/v2/products/shipping_classes/<id>
curl https://example.com/wp-json/wc/v2/products/shipping_classes/32 \
-u consumer_key:consumer_secret

List all shipping classes

This API lets you retrieve all product shipping classes.

GET /wp-json/wc/v2/products/shipping_classes
curl https://example.com/wp-json/wc/v2/products/shipping_classes \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to those matching a string.
excludearrayEnsure result set excludes specific ids.
includearrayLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is asc.
orderbystringSort collection by resource attribute. Options: id, include, name, slug, term_group, description and count. Default is name.
hide_emptybooleanWhether to hide resources not assigned to any products. Default is false.
productintegerLimit result set to resources assigned to a specific product.
slugstringLimit result set to resources with a specific slug.

Update a shipping class

This API lets you make changes to a product shipping class.

PUT /wp-json/wc/v2/products/shipping_classes/<id>
curl -X PUT https://example.com/wp-json/wc/v2/products/shipping_classes/32 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"description": "Priority mail."
}'

Delete a shipping class

This API helps you delete a product shipping class.

DELETE /wp-json/wc/v2/products/shipping_classes/<id>
curl -X DELETE https://example.com/wp-json/wc/v2/products/shipping_classes/32?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringRequired to be true, as resource does not support trashing.

Batch update shipping classes

This API helps you to batch create, update and delete multiple product shipping classes.

note

Note: By default it's limited to up to 100 objects to be created, updated or deleted.

POST /wp-json/wc/v2/products/shipping_classes/batch
curl -X POST https://example.com/wp-json/wc/v2/products/shipping_classes/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Small items"
},
{
"name": "Large items"
}
],
"update": [
{
"id": 33,
"description": "Express shipping"
}
],
"delete": [
32
]
}'