# 配送方式 #

配送方式 API 允许您查看单个配送方式。

## 配送方式属性 ##

| 属性          | 类型   | 描述                                                              |
| ------------- | ------ | ------------------------------------------------------------------ |
| `id`          | string | 方法 ID。<i class="label label-info">只读</i>                     |
| `title`       | string | 配送方式标题。<i class="label label-info">只读</i>               |
| `description` | string | 配送方式描述。<i class="label label-info">只读</i>               |

## 获取配送方式 ##

此 API 允许您检索并查看特定的配送方式。

### HTTP 请求 ###

<div class="api-endpoint">
	<div class="endpoint-data">
		<i class="label label-get">GET</i>
		<h6>/wp-json/wc/v2/shipping_methods/&lt;id&gt;</h6>
	</div>
</div>

```shell
curl https://example.com/wp-json/wc/v2/shipping_methods/flat_rate \
	-u consumer_key:consumer_secret
```

```javascript
WooCommerce.get("shipping_methods/flat_rate")
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.log(error.response.data);
  });
```

```php
<?php print_r($woocommerce->get('shipping_methods/flat_rate')); ?>
```

```python
print(wcapi.get("shipping_methods/flat_rate").json())
```

```ruby
woocommerce.get("shipping_methods/flat_rate").parsed_response
```

> JSON 响应示例：

```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/v2/shipping_methods/flat_rate"
      }
    ],
    "collection": [
      {
        "href": "https://example.com/wp-json/wc/v2/shipping_methods"
      }
    ]
  }
}
```

## 列出所有配送方式 ##

此 API 可帮助您查看所有配送方式。

### HTTP 请求 ###

<div class="api-endpoint">
	<div class="endpoint-data">
		<i class="label label-get">GET</i>
		<h6>/wp-json/wc/v2/shipping_methods</h6>
	</div>
</div>

```shell
curl https://example.com/wp-json/wc/v2/shipping_methods \
	-u consumer_key:consumer_secret
```

```javascript
WooCommerce.get("shipping_methods")
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.log(error.response.data);
  });
```

```php
<?php print_r($woocommerce->get('shipping_methods')); ?>
```

```python
print(wcapi.get("shipping_methods").json())
```

```ruby
woocommerce.get("shipping_methods").parsed_response
```

> JSON 响应示例：

```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/v2/shipping_methods/flat_rate"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/wc/v2/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/v2/shipping_methods/free_shipping"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/wc/v2/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/v2/shipping_methods/local_pickup"
        }
      ],
      "collection": [
        {
          "href": "https://example.com/wp-json/wc/v2/shipping_methods"
        }
      ]
    }
  }
]
```