Draft Order Resource
Content
- Create Draft Order
- Update Draft Order
- Get a list of Draft Orders
- Get a single Draft Order
- Get Draft Orders Count
- Delete a Draft Order
- Complete a Draft Order
- Complete a Draft Order, marking it as pending
Create Draft Order
POST /api/draft_orders.json
- POST /api/draft_orders.json will create a new Draft Order from the parameters passed.
Example:
Create Draft Order with existing product
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X POST \
-d \
' {
"draft_order": {
"items": [
{
"product_id": 1455064,
"quantity": 1
}
],
"billing_address": {
"firstname": "my firstname",
"lastname": "my lastname",
"street": "my street",
"streetnumber": 1,
"zipcode": 12345,
"city": "Hannover"},
"shipping_address": {
"firstname": "my firstname",
"lastname": "my lastname",
"street": "mystreet",
"streetnumber": 1,
"zipcode": 12345,
"city": "Hannover"
}
}
} ' \
https://shop_subdomain.versacommerce.de/api/draft_orders.json
Create Draft Order with custom product
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X POST \
-d \
' {
"draft_order": {
"items": [
{
"title": "Custom Tee",
"price": "20.00",
"quantity": 2
}
],
"billing_address": {
"firstname": "my firstname",
"lastname": "my lastname",
"street": "my street",
"streetnumber": 1,
"zipcode": 12345,
"city": "Hannover"},
"shipping_address": {
"firstname": "my firstname",
"lastname": "my lastname",
"street": "mystreet",
"streetnumber": 1,
"zipcode": 12345,
"city": "Hannover"
}
}
} ' \
https://shop_subdomain.versacommerce.de/api/draft_orders.json
Create Draft Order with existing customer and product
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X POST \
-d \
' {
"draft_order": {
"items": [
{
"product_id": 1455064,
"quantity": 1
}
],
"customer": {
"id": 1491033
}
}
} ' \
https://shop_subdomain.versacommerce.de/api/draft_orders.json
# A draft order must at least contain one item with the following attributes:
draft_order[items][][product_id] = 12345 # Position: VersaCommerce Product ID draft_order[items][][quantity] = 3 # Position: Anzahl
# If you create a draft order with 'custom items', it should contain:
draft_order[items][title] = '...' # Position: Titel draft_order[items][price] = 10.99 # Position: Einzelpreis draft_order[items][quantity] = 1
# A draft order must contain a billing address with the following attributes:
draft_order[shipping_address][firstname] = '...' # Lieferadresse: Vorname draft_order[shipping_address][lastname] = '...' # Lieferadresse: Nachname draft_order[shipping_address][street] = '...' # Lieferadresse: Straße draft_order[shipping_address][streetnumber] = '...' # Lieferadresse: Hausnummer draft_order[shipping_address][zipcode] = '...' # Lieferadresse: PLZ draft_order[shipping_address][city] = '...' # Lieferadresse: Stadt draft_order[billing_address][firstname] = '...' # Rechnungsadresse: Vorname draft_order[billing_address][lastname] = '...' # Rechnungsadresse: Nachname draft_order[billing_address][street] = '...' # Rechnungsadresse: Straße draft_order[billing_address][streetnumber] = '...' # Rechnungsadresse: Hausnummer draft_order[billing_address][zipcode] = '...' # Rechnungsadresse: PLZ draft_order[billing_address][city] = '...' # Rechnungsadresse: Stadt
Update Draft Order
PUT /api/draft_orders/:draft_order_id.json
- PUT /api/draft_orders/:draft_order_id.json will modify an existing error
Add a note to a draft order
Example:
$ curl -s \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-u APP_API_KEY:APP_API_PASSWORD \
-X PUT \
-d \
'{
"draft_order": {
"id": 123344,
"note": "Customer contacted us about a custom iPod"
}
}' \
https://shop_subdomain.versacommerce.de/api/draft_orders/:draft_order_id.json
Status: 202
{
"draft_order": {
"code": "xxx-xxx-xxx",
"completed_at": null,
"coupon_code": null,
"coupon_value": "0.0",
"created_at": "2021-08-18T08:38:01+02:00",
"customer_email": "support@versacommerce.de",
"customer_id": 1534767,
"discount_total": "0.0",
"id": 1184,
"item_total": "51.0",
"items_count": 0,
"name": null,
"note": "Customer contacted us about a custom iPod",
"order_id": null,
"payment_cost": null,
"payment_status": "not_paid",
"prices_include_tax": true,
"reduced_tax_amount": "1.596638655462184873949579831",
"reduced_tax_rate": 19.0,
"reduced_tax_total": "10.0",
"reservation_id": null,
"shipping_cost": null,
"shipping_type": null,
"shop_id": xxxx,
"standard_tax_amount": "6.54621848739495798319327731",
"standard_tax_rate": "19.0",
"standard_tax_total": "41.0",
"status": null,
"subtotal": "51.0",
"timestamps": null,
"total": "51.0",
"updated_at": "2021-08-18T11:28:52+02:00"
}
}
Get a list of Draft Orders
GET /api/draft_orders.json
- GET /api/draft_orders.json will return the first 150 (default limit) orders. You can increase the limit to a maximum of 250 orders. You can pass a limit filter like GET /api/draft_orders.json?limit=10
Example:
$ curl -s \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -u APP_API_KEY:APP_API_PASSWORD \ -X GET \ https://shop_subdomain.versacommerce.de/api/draft_orders.json
Get a single Draft Order
GET /api/draft_orders/:draft_order_id.json
- GET /api/draft_orders/:draft_order_id.json will return the specified order.
Example:
$ curl -s \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -u APP_API_KEY:APP_API_PASSWORD \ -X GET \ https://shop_subdomain.versacommerce.de/api/draft_orders/:draft_order_id.json
Status: 200 OK
{
"draft_order": {
"code": "xxx-xxx-xxx",
"completed_at": null,
"coupon_code": null,
"coupon_value": "0.0",
"created_at": "2021-08-06T15:29:32+02:00",
"customer_email": "support@versacommerce.de",
"customer_id": 792525,
"discount_total": "0.0",
"id": 1146,
"item_total": "10.0",
"items_count": 0,
"name": null,
"note": "",
"order_id": null,
"payment_cost": "0.0",
"payment_status": "not_paid",
"prices_include_tax": true,
"reduced_tax_amount": "1.6",
"reduced_tax_rate": 19.0,
"reduced_tax_total": "10.0",
"reservation_id": null,
"shipping_cost": "0.0",
"shipping_type": null,
"shop_id": 13885,
"standard_tax_amount": "0.0",
"standard_tax_rate": "19.0",
"standard_tax_total": "0.0",
"status": null,
"subtotal": "10.0",
"timestamps": null,
"total": "10.0",
"updated_at": "2021-08-10T16:38:00+02:00",
"items": [{
"asin": null,
"carrier_id": null,
"category": null,
"code": null,
"current_status_on": null,
"discount": 0.0,
"discount_amount": "0.0",
"discount_price": null,
"discount_type": "money",
"draft_order_id": 1146,
"editable_quantity": null,
"editable_shipping_type": null,
"extra_price": null,
"height": 0.0,
"id": 2788146,
"length": 0.0,
"line_height": 0.0,
"line_length": 0.0,
"line_price": "10.0",
"line_tax": "1.596638655462184873949579831",
"line_weight": 0.0,
"line_width": 0.0,
"option_01": null,
"option_01_label": null,
"option_02": null,
"option_02_label": null,
"option_03": null,
"option_03_label": null,
"options": null,
"order_id": null,
"origin_id": null,
"original_price": null,
"price": "10.0",
"product_id": 1455064,
"quantity": 1,
"shipment_id": null,
"shipping_address_id": null,
"shipping_type": null,
"status": "undelivered",
"subtitle": null,
"tax_rate": "19.0",
"title": null,
"vendor": null,
"weight": 0.0,
"width": 0.0
}],
"billing_address": {
"category": "billing",
"city": "2",
"company": "",
"country": "DE",
"customer_id": 792525,
"draft_order_id": 1146,
"email": "support@versacommerce.de",
"extension": null,
"firstname": "George",
"id": 6364355,
"lastname": "Hill",
"locked": false,
"option_01": null,
"option_02": null,
"option_03": null,
"order_id": null,
"phone": null,
"state": "unbekannt",
"street": "Bodekestrasse",
"streetnumber": "22",
"title": "",
"zipcode": "30161"
},
"shipping_address": {
"category": "shipping",
"city": "2",
"company": "",
"country": "DE",
"customer_id": 792525,
"draft_order_id": 1146,
"email": "support@versacommerce.de",
"extension": null,
"firstname": "George",
"id": 6364354,
"lastname": "Hill",
"locked": false,
"option_01": null,
"option_02": null,
"option_03": null,
"order_id": null,
"phone": null,
"state": "unbekannt",
"street": "Bodekestrasse",
"streetnumber": "22",
"title": "",
"zipcode": "30161"
}
}
}
Get Draft Orders Count
GET /api/orders/count.json
- GET /api/orders/count.json will return the orders count.
Example:
$ curl -s \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -u APP_API_KEY:APP_API_PASSWORD \ -X GET \ https://shop_subdomain.versacommerce.de/api/draft_orders/count.json
Status: 200 OK
{
"count": 117
}
Delete a Draft Order
DELETE api/draft_orders/:draft_order_id.json
- DELETE api/draft_orders/:draft_order_id.json permanently delete a draft order
Example:
$ curl -s
\ -H 'Accept: application/json'
\ -H 'Content-Type: application/json'
\ -u APP_API_KEY:APP_API_PASSWORD
\ -X DELETE \
https://shop_subdomain.versacommerce.de/api/draft_orders/:draft_order_id.json
Status: 200 OK
{
}
Complete a Draft Order
PUT /api/draft_orders/:draft_order_id/complete.json
- PUT /api/draft_orders/:draft_order_id/complete.json will complete a draft order, marking it as paid.
- payment_pending
- true: Sets payment pending to true
- false: Sets payment pending to false. default value.
$ curl -s \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -u APP_API_KEY:APP_API_PASSWORD \ -X PUT \ https://shop_subdomain.versacommerce.de/api/draft_orders/:draft_order_id/complete.json
Status: 200 OK
{
"draft_order": {
"code": "xxx-xxx-xxx",
"completed_at": "2021-08-10T15:48:42+02:00",
"coupon_code": null,
"coupon_value": "0.0",
"created_at": "2021-08-06T15:40:47+02:00",
"customer_email": "support@versacommerce.de",
"customer_id": "12345",
"discount_total": "0.0",
"id": 1148,
"item_total": "10.0",
"items_count": 1,
"name": null,
"note": "",
"order_id": 1747685,
"payment_cost": "0.0",
"payment_status": "paid",
"prices_include_tax": true,
"reduced_tax_amount": "1.6",
"reduced_tax_rate": 19.0,
"reduced_tax_total": "10.0",
"reservation_id": null,
"shipping_cost": "0.0",
"shipping_type": null,
"shop_id": 13885,
"standard_tax_amount": "0.0",
"standard_tax_rate": "19.0",
"standard_tax_total": "0.0",
"status": "completed",
"subtotal": "10.0",
"timestamps": null,
"total": "10.0",
"updated_at": "2021-08-10T15:48:44+02:00",
"items": [{
"asin": null,
"carrier_id": null,
"category": null,
"code": null,
"current_status_on": null,
"discount": 0.0,
"discount_amount": "0.0",
"discount_price": null,
"discount_type": "money",
"draft_order_id": 1148,
"editable_quantity": null,
"editable_shipping_type": null,
"extra_price": null,
"height": 0.0,
"id": 2788148,
"length": 0.0,
"line_height": 0.0,
"line_length": 0.0,
"line_price": "10.0",
"line_tax": "1.596638655462184873949579831",
"line_weight": 0.0,
"line_width": 0.0,
"option_01": null,
"option_01_label": null,
"option_02": null,
"option_02_label": null,
"option_03": null,
"option_03_label": null,
"options": null,
"order_id": 1747685,
"origin_id": null,
"original_price": null,
"price": "10.0",
"product_id": 1455064,
"quantity": 1,
"shipment_id": null,
"shipping_address_id": null,
"shipping_type": null,
"status": "undelivered",
"subtitle": null,
"tax_rate": "19.0",
"title": null,
"vendor": null,
"weight": 0.0,
"width": 0.0
}],
"billing_address": {
"category": "billing",
"city": "2",
"company": "",
"country": "DE",
"customer_id": 792525,
"draft_order_id": 1148,
"email": "support@versacommerce.de",
"extension": null,
"firstname": "George",
"id": 6364343,
"lastname": "Hill",
"locked": false,
"option_01": null,
"option_02": null,
"option_03": null,
"order_id": null,
"phone": null,
"state": "unbekannt",
"street": "Example street",
"streetnumber": "12",
"title": "",
"zipcode": "30161"
},
"shipping_address": {
"category": "shipping",
"city": "2",
"company": "",
"country": "DE",
"customer_id": 792525,
"draft_order_id": 1148,
"email": "support@versacommerce.de",
"extension": null,
"firstname": "George",
"id": 6364342,
"lastname": "Hill",
"locked": false,
"option_01": null,
"option_02": null,
"option_03": null,
"order_id": null,
"phone": null,
"state": "unbekannt",
"street": "Example street",
"streetnumber": "12",
"title": "",
"zipcode": "30161"
}
}
}
Complete a draft order, marking it as pending
- PUT /admin/api/2021-07/draft_orders/:draft_order_id/complete.json?payment_pending=true
Example:
$ curl -s \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -u APP_API_KEY:APP_API_PASSWORD \ -X PUT \ https://shop_subdomain.versacommerce.de/api/draft_orders/:draft_order_id/complete.json?payment_pending=true
Status: 200 OK
{
"draft_order": {
"code": "xxx-xxx-xxx",
"completed_at": "2021-08-10T16:09:30+02:00",
"coupon_code": null,
"coupon_value": "0.0",
"created_at": "2021-08-06T15:33:00+02:00",
"customer_email": "support@versacommerce.de",
"customer_id": 792525,
"discount_total": "0.0",
"id": 1147,
"item_total": "10.0",
"items_count": 1,
"name": null,
"note": "",
"order_id": 1747686,
"payment_cost": "0.0",
"payment_status": "not_paid",
"prices_include_tax": true,
"reduced_tax_amount": "1.6",
"reduced_tax_rate": 19.0,
"reduced_tax_total": "10.0",
"reservation_id": null,
"shipping_cost": "0.0",
"shipping_type": null,
"shop_id": 13885,
"standard_tax_amount": "0.0",
"standard_tax_rate": "19.0",
"standard_tax_total": "0.0",
"status": "open",
"subtotal": "10.0",
"timestamps": null,
"total": "10.0",
"updated_at": "2021-08-10T16:09:31+02:00",
"items": [{
"asin": null,
"carrier_id": null,
"category": null,
"code": null,
"current_status_on": null,
"discount": 0.0,
"discount_amount": "0.0",
"discount_price": null,
"discount_type": "money",
"draft_order_id": 1147,
"editable_quantity": null,
"editable_shipping_type": null,
"extra_price": null,
"height": 0.0,
"id": 2788147,
"length": 0.0,
"line_height": 0.0,
"line_length": 0.0,
"line_price": "10.0",
"line_tax": "1.596638655462184873949579831",
"line_weight": 0.0,
"line_width": 0.0,
"option_01": null,
"option_01_label": null,
"option_02": null,
"option_02_label": null,
"option_03": null,
"option_03_label": null,
"options": null,
"order_id": 1747686,
"origin_id": null,
"original_price": null,
"price": "10.0",
"product_id": 1455064,
"quantity": 1,
"shipment_id": null,
"shipping_address_id": null,
"shipping_type": null,
"status": "undelivered",
"subtitle": null,
"tax_rate": "19.0",
"title": null,
"vendor": null,
"weight": 0.0,
"width": 0.0
}],
"billing_address": {
"category": "billing",
"city": "2",
"company": "",
"country": "DE",
"customer_id": 792525,
"draft_order_id": 1147,
"email": "support@versacommerce.de",
"extension": null,
"firstname": "George",
"id": 6364349,
"lastname": "Hill",
"locked": false,
"option_01": null,
"option_02": null,
"option_03": null,
"order_id": null,
"phone": null,
"state": "unbekannt",
"street": "Example street",
"streetnumber": "12",
"title": "",
"zipcode": "30161"
},
"shipping_address": {
"category": "shipping",
"city": "2",
"company": "",
"country": "DE",
"customer_id": 792525,
"draft_order_id": 1147,
"email": "support@versacommerce.de",
"extension": null,
"firstname": "George",
"id": 6364348,
"lastname": "Hill",
"locked": false,
"option_01": null,
"option_02": null,
"option_03": null,
"order_id": null,
"phone": null,
"state": "unbekannt",
"street": "Example street",
"streetnumber": "12",
"title": "",
"zipcode": "30161"
}
}
}