Back to Woocommerce

Shipping methods

docs/apis/rest-api/v3/shipping-methods.mdx

10.9.0-dev4.1 KB
Original Source

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Shipping methods

The shipping methods API allows you to view individual shipping methods.

Shipping method properties

AttributeTypeDescription
idstringMethod ID. READ-ONLY
titlestringShipping method title. READ-ONLY
descriptionstringShipping method description. READ-ONLY

Retrieve a shipping method

This API lets you retrieve and view a specific shipping method.

http
GET /wp-json/wc/v3/shipping_methods/<id>
<Tabs> <TabItem value="curl" label="cURL">
shell
curl https://example.com/wp-json/wc/v3/shipping_methods/flat_rate \
	-u consumer_key:consumer_secret
</TabItem> <TabItem value="js" label="JavaScript">
javascript
WooCommerce.get( 'shipping_methods/flat_rate' )
	.then( ( response ) => {
		console.log( response.data );
	} )
	.catch( ( error ) => {
		console.log( error.response.data );
	} );
</TabItem> <TabItem value="php" label="PHP">
php
<?php print_r($woocommerce->get('shipping_methods/flat_rate')); ?>
</TabItem> <TabItem value="python" label="Python">
python
print(wcapi.get("shipping_methods/flat_rate").json())
</TabItem> <TabItem value="ruby" label="Ruby">
ruby
woocommerce.get("shipping_methods/flat_rate").parsed_response
</TabItem> <TabItem value="response" label="JSON Response">
json
{
	"id": "flat_rate",
	"title": "Flat rate",
	"description": "Lets you charge a fixed rate for shipping.",
	"_links": {
		"self": [
			{
				"href": "https://example.com/wp-json/wc/v3/shipping_methods/flat_rate"
			}
		],
		"collection": [
			{
				"href": "https://example.com/wp-json/wc/v3/shipping_methods"
			}
		]
	}
}
</TabItem> </Tabs>

List all shipping methods

This API helps you to view all the shipping methods.

http
GET /wp-json/wc/v3/shipping_methods
<Tabs> <TabItem value="curl" label="cURL">
shell
curl https://example.com/wp-json/wc/v3/shipping_methods \
	-u consumer_key:consumer_secret
</TabItem> <TabItem value="js" label="JavaScript">
javascript
WooCommerce.get( 'shipping_methods' )
	.then( ( response ) => {
		console.log( response.data );
	} )
	.catch( ( error ) => {
		console.log( error.response.data );
	} );
</TabItem> <TabItem value="php" label="PHP">
php
<?php print_r($woocommerce->get('shipping_methods')); ?>
</TabItem> <TabItem value="python" label="Python">
python
print(wcapi.get("shipping_methods").json())
</TabItem> <TabItem value="ruby" label="Ruby">
ruby
woocommerce.get("shipping_methods").parsed_response
</TabItem> <TabItem value="response" label="JSON Response">
json
[
	{
		"id": "flat_rate",
		"title": "Flat rate",
		"description": "Lets you charge a fixed rate for shipping.",
		"_links": {
			"self": [
				{
					"href": "https://example.com/wp-json/wc/v3/shipping_methods/flat_rate"
				}
			],
			"collection": [
				{
					"href": "https://example.com/wp-json/wc/v3/shipping_methods"
				}
			]
		}
	},
	{
		"id": "free_shipping",
		"title": "Free shipping",
		"description": "Free shipping is a special method which can be triggered with coupons and minimum spends.",
		"_links": {
			"self": [
				{
					"href": "https://example.com/wp-json/wc/v3/shipping_methods/free_shipping"
				}
			],
			"collection": [
				{
					"href": "https://example.com/wp-json/wc/v3/shipping_methods"
				}
			]
		}
	},
	{
		"id": "local_pickup",
		"title": "Local pickup",
		"description": "Allow customers to pick up orders themselves. By default, when using local pickup store base taxes will apply regardless of customer address.",
		"_links": {
			"self": [
				{
					"href": "https://example.com/wp-json/wc/v3/shipping_methods/local_pickup"
				}
			],
			"collection": [
				{
					"href": "https://example.com/wp-json/wc/v3/shipping_methods"
				}
			]
		}
	}
]
</TabItem> </Tabs>