|
| 1 | +# Order Subscriptions # |
| 2 | + |
| 3 | +The order subscriptions API endpoint enables you to view subscriptions related to a specific order. |
| 4 | + |
| 5 | +## Query parameters ## |
| 6 | + |
| 7 | +| Parameter | Type | Description | |
| 8 | +|-----------------|--------|------------------------------------------------------------------------------------------------| |
| 9 | +| `status` | string | Limit result set to subscriptions assigned a specific status. Options: `pending`, `active`, `on-hold`, `cancelled`, `switched`, `expired`, `pending-cancel` and `trash`. Default is `any`. | |
| 10 | +| `customer` | integer | Limit result set to subscriptions assigned to a specific customer. | |
| 11 | +| `orderby` | string | Sort collection by object attribute. Options: `date`, `id`, `include`, `title`, `slug` and `modified`. Default is `date`. | |
| 12 | +| `order` | string | Order sort attribute ascending or descending. Options: `asc` and `desc`. Default is `desc`. | |
| 13 | +| `_fields` | string | Limit response to specific fields. Expects a comma-separated list of fields. | |
| 14 | + |
| 15 | +## Retrieve order subscriptions ## |
| 16 | + |
| 17 | +This API lets you retrieve and view subscriptions for a specific order. |
| 18 | +Available since v7.9.0 |
| 19 | + |
| 20 | +### HTTP request ### |
| 21 | + |
| 22 | +<div class="api-endpoint"> |
| 23 | + <div class="endpoint-data"> |
| 24 | + <i class="label label-get">GET</i> |
| 25 | + <h6>/wp-json/wc/v3/orders/<id>/subscriptions</h6> |
| 26 | + </div> |
| 27 | +</div> |
| 28 | + |
| 29 | +```shell |
| 30 | +curl https://example.com/wp-json/wc/v3/orders/1274/subscriptions \ |
| 31 | + -u consumer_key:consumer_secret |
| 32 | +``` |
| 33 | + |
| 34 | +```javascript |
| 35 | +WooCommerce.get('orders/1274/subscriptions', function(err, data, res) { |
| 36 | + console.log(res); |
| 37 | +}); |
| 38 | +``` |
| 39 | + |
| 40 | +```php |
| 41 | +<?php print_r($woocommerce->get('orders/1274/subscriptions')); ?> |
| 42 | +``` |
| 43 | + |
| 44 | +```python |
| 45 | +print(wcapi.get("orders/1274/subscriptions").json()) |
| 46 | +``` |
| 47 | + |
| 48 | +```ruby |
| 49 | +woocommerce.get("orders/1274/subscriptions").parsed_response |
| 50 | +``` |
| 51 | + |
| 52 | +> JSON response example: |
| 53 | +
|
| 54 | +```json |
| 55 | +[ |
| 56 | + { |
| 57 | + "id": 1275, |
| 58 | + "parent_id": 1274, |
| 59 | + "status": "active", |
| 60 | + "currency": "USD", |
| 61 | + "version": "5.2.0", |
| 62 | + "prices_include_tax": true, |
| 63 | + "date_created": "2021-04-19T17:20:56", |
| 64 | + "date_modified": "2021-04-19T17:21:00", |
| 65 | + "discount_total": "0.00", |
| 66 | + "discount_tax": "0.00", |
| 67 | + "shipping_total": "0.00", |
| 68 | + "shipping_tax": "0.00", |
| 69 | + "cart_tax": "2.37", |
| 70 | + "total": "26.09", |
| 71 | + "total_tax": "2.37", |
| 72 | + "customer_id": 1, |
| 73 | + "order_key": "wc_order_6fS6FmzoZohhR", |
| 74 | + "billing": { |
| 75 | + "first_name": "James", |
| 76 | + "last_name": "Allan", |
| 77 | + "company": "", |
| 78 | + "address_1": "1 Main Rd", |
| 79 | + "address_2": "", |
| 80 | + "city": "Brisbane", |
| 81 | + "state": "QLD", |
| 82 | + "postcode": "4000", |
| 83 | + "country": "AU", |
| 84 | + "email": "james@example.com", |
| 85 | + "phone": "0000000000" |
| 86 | + }, |
| 87 | + "shipping": { |
| 88 | + "first_name": "James", |
| 89 | + "last_name": "Allan", |
| 90 | + "company": "", |
| 91 | + "address_1": "1 Main Rd", |
| 92 | + "address_2": "", |
| 93 | + "city": "Brisbane", |
| 94 | + "state": "QLD", |
| 95 | + "postcode": "4000", |
| 96 | + "country": "AU" |
| 97 | + }, |
| 98 | + "payment_method": "stripe", |
| 99 | + "payment_method_title": "Credit Card (Stripe)", |
| 100 | + "customer_ip_address": "192.0.2.1", |
| 101 | + "customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36", |
| 102 | + "created_via": "checkout", |
| 103 | + "customer_note": "", |
| 104 | + "cart_hash": "413996ccaa9ff9e1d3375a5f919a6ba3", |
| 105 | + "number": "1275", |
| 106 | + "meta_data": [ |
| 107 | + { |
| 108 | + "id": 52020, |
| 109 | + "key": "is_vat_exempt", |
| 110 | + "value": "no" |
| 111 | + } |
| 112 | + ], |
| 113 | + "line_items": [ |
| 114 | + { |
| 115 | + "id": 1605, |
| 116 | + "name": "Weekly", |
| 117 | + "product_id": 1027, |
| 118 | + "variation_id": 0, |
| 119 | + "quantity": 3, |
| 120 | + "tax_class": "", |
| 121 | + "subtotal": "23.72", |
| 122 | + "subtotal_tax": "2.37", |
| 123 | + "total": "23.72", |
| 124 | + "total_tax": "2.37", |
| 125 | + "taxes": [ |
| 126 | + { |
| 127 | + "id": 2, |
| 128 | + "total": "2.371541", |
| 129 | + "subtotal": "2.371541" |
| 130 | + } |
| 131 | + ], |
| 132 | + "meta_data": [], |
| 133 | + "sku": "", |
| 134 | + "price": 7.9051383333333334, |
| 135 | + "parent_name": null |
| 136 | + } |
| 137 | + ], |
| 138 | + "tax_lines": [ |
| 139 | + { |
| 140 | + "id": 1606, |
| 141 | + "rate_code": "US-TAX-1", |
| 142 | + "rate_id": 2, |
| 143 | + "label": "TAX", |
| 144 | + "compound": true, |
| 145 | + "tax_total": "2.37", |
| 146 | + "shipping_tax_total": "0.00", |
| 147 | + "rate_percent": 10, |
| 148 | + "meta_data": [] |
| 149 | + } |
| 150 | + ], |
| 151 | + "shipping_lines": [], |
| 152 | + "fee_lines": [], |
| 153 | + "coupon_lines": [], |
| 154 | + "date_created_gmt": "2021-04-19T07:20:56", |
| 155 | + "date_modified_gmt": "2021-04-19T07:21:00", |
| 156 | + "start_date": "2021-04-19T17:20:56", |
| 157 | + "trial_end_date": null, |
| 158 | + "next_payment_date": "2021-04-26T17:20:56", |
| 159 | + "end_date": null, |
| 160 | + "billing_period": "week", |
| 161 | + "billing_interval": "1", |
| 162 | + "_links": { |
| 163 | + "self": [ |
| 164 | + { |
| 165 | + "href": "https://example.com/wp-json/wc/v3/subscriptions/1275" |
| 166 | + } |
| 167 | + ], |
| 168 | + "collection": [ |
| 169 | + { |
| 170 | + "href": "https://example.com/wp-json/wc/v3/orders/1274/subscriptions" |
| 171 | + } |
| 172 | + ], |
| 173 | + "parent_order": [ |
| 174 | + { |
| 175 | + "href": "https://example.com/wp-json/wc/v3/orders/1274" |
| 176 | + } |
| 177 | + ], |
| 178 | + "customer": [ |
| 179 | + { |
| 180 | + "href": "https://example.com/wp-json/wc/v3/customers/1" |
| 181 | + } |
| 182 | + ] |
| 183 | + } |
| 184 | + } |
| 185 | +] |
| 186 | +``` |
| 187 | + |
0 commit comments