Create Order
Notice
Without calculate delivery_fee and payment_fee
目前尚未支援附加費與運費的計入
Function
To create an order with open API
透過 API 創建一筆新訂單
Note : 不支援創建定期購訂單。
URL
POST <<api_domain>>/v1/orders
Request Parameters
Parameter | Type | Description | Example |
---|---|---|---|
order.delivery_option_id *Required | String | ID of Delivery Option 出貨方式之ID - *Currently not allowed third party delivery providers 暫不支援第三方物流串接方式 | ruby "delivery_option_id":"58d3379401cda31bfb000000" |
order.payment_method_id *Required | String | ID of Payment Option 付款方式之ID - *Currently not allowed third party payment service 暫不支援第三方金流串接方式 | ruby "payment_method_id": "58d25b9d01cda3475300002d" |
order.subtotal *Required | Float | Price Total for all order items 訂單小計,包含所有商品總價 | ruby "subtotal": 3699 |
order.total *Required | Float | Final price total, including credits and discounts deducted. 付款總金額,為訂單小計扣除購物金與折扣 - *Delivery fee and payment fee are not calculated 目前尚未支援附加費與運費的計入 | ruby "total":3199 |
order.items *Required | Array | Order product Item Data 訂單中商品資訊,支援規格品 | ruby "items":[ { "item_type":"Product", "item_id":"5adedc00e388094414000033", "variation_id":"66b09f05879c87001594d9b8", "item_price": 999, "quantity": 1, "total": 999 } |
order.customer_id *必須和order.customer_email擇一Required | String | Customer ID 顧客ID | ruby "customer_id":"5e0047dfc4101900263b1450" |
order.customer_email *必須和order.customer_id擇一Required | String | Customer's Email 顧客Email | ruby "customer_email":"[email protected]" |
order.customer_phone | String | Customer's Phone 顧客電話 | ruby "customer_phone":"0910123456" |
order.delivery_address *Required | Order DeliveryAddress | Delivery Address Information 運送地址資訊 | ruby "delivery_address": { "city": "台北市", "postcode": "10560", "address_2": "松山區", "address_1": "光復北路11巷44號14樓", "recipient_name": "Flash", "recipient_phone": "0227423966" "country": "台灣", "country_code": "TW" } |
order.order_remarks | String | Add order remark to the order, cannot be updated via patch | |
order.user_credit | Integer | Credits used for the order 訂單所使用之折抵購物金 | ruby "user_credit"=30 |
order.member_point | Number | Applied Member Point 已使用會員點數 | 120 |
order.opt_in_auto_reward | 'Boolean' | Apply "Order Reward Credits" automatically 自動發送"滿額送購物金" [Note] - 僅支援 適用渠道 包含 網店 的全單滿額回饋活動- 不支援指定分類或商品的購物金發送*Default: false | ruby "opt_in_auto_reward"=true |
is_registering_as_member | Boolean | Do you want to set the customer as a member? 是否要將此筆訂單顧客設為會員? - *Default: false | ruby "is_registering_as_member": true |
is_inventory_fulfillment | Boolean | Do you want to deduct the inventory numbers after the order is created? 此筆訂單是否要扣掉庫存? - *Default:false | ruby "is_inventory_fulfillment": true |
mail_notify | Boolean | Do you want to notify the customer of the order creation by email ? 此筆訂單成立之後是否要通知顧客? - *Default:false | ruby "mail_notify": false |
。
*出貨方式/付款方式的ID可以由編輯頁面的url得到
Request Example
Create an order with items, Product, CustomProduct, CustomDiscount
curl -X POST \
<<api_domain>>/v1/orders \
-H 'Authorization: Bearer access_token' \
-H 'Content-Type: application/json' \
-d '{
"order": {
"delivery_option_id": "58d3379401cda31bfb000000",
"payment_method_id": "58d25b9d01cda3475300002d",
"subtotal": "3699",
"total": "3199",
"items":[
{
"item_type": "Product",
"item_id": "5adedc00e388094414000033",
"item_price": 999,
"quantity": 1,
"total": 999
},{
"item_type": "Product",
"item_id": "5a8165fbe38809548f0000fd",
"variation_id": "5ad5ba52d2a93e6616000010",
"item_price": 1500,
"quantity": 1,
"total": 1500
},{
"item_type": "CustomDiscount",
"item_price": 500,
"total": 500,
"item_data": {
"name": "DDD"
}
},{
"item_type": "CustomProduct",
"item_price": 600,
"item_data": {
"name": "Custom Product Name",
"price": "600"
},
"quantity": 2,
"total": 1200
}
],
"customer_email": "[email protected]",
"customer_phone": "0910123456",
"delivery_address": {
"city": "台北市",
"postcode": "10560",
"address_2": "松山區",
"address_1": "光復北路11巷44號14樓",
"recipient_name": "Flash",
"recipient_phone": "0227423966",
"country": "台灣",
"country_code": "TW"
},
"order_remarks": "Create my order remark",
"user_credit": 0,
"opt_in_auto_reward": false,
},
"is_registering_as_member": false,
"is_inventory_fulfillment": false,
"mail_notify": false,
"created_from": "admin_openapi"
}'
Response Example
Also same with Get Order
{
"affiliate_data" : {},
"channel" : {},
"child_order_ids" : [],
"confirmed_at" : null,
"created_at" : "2021-05-31T03:17:48.055+00:00",
"created_by" : "openapi",
"created_from" : "admin_openapi",
"currency_iso" : "HKD",
"custom_data" : [],
"custom_discount_items" : [],
"customer_email" : "[email protected]",
"customer_id" : "6017ac19f1231200287bd3a7",
"customer_info" : {},
"customer_name" : "louis",
"customer_phone" : "2345677",
"delivery_address" : {
"address_1" : null,
"address_2" : null,
"city" : null,
"country" : null,
"country_code" : null,
"district" : null,
"key" : null,
"layer1" : null,
"layer2" : null,
"layer3" : null,
"logistic_codes" : null,
"postcode" : null,
"recipient_name" : "louis",
"recipient_phone" : "13823292627",
"remarks" : null,
"state" : null
},
"delivery_data" : {
"hk_sfplus_home_region" : null,
"location_code" : null,
"location_name" : null,
"name_translations" : null,
"scheduled_delivery_date" : null,
"store_address" : null,
"time_slot_key" : null,
"time_slot_translations" : {},
"tracking_number" : "",
"url" : null
},
"ga_tracked" : false,
"id" : "60b4555be02b9b001f421a6a",
"invoice" : {
"buyer_name" : "",
"carrier_number" : "",
"carrier_type" : "",
"invoice_cancelled_at" : null,
"invoice_date" : null,
"invoice_number" : "",
"invoice_status" : "",
"invoice_tax_type" : "",
"invoice_type" : "",
"mailing_address" : "",
"n_p_o_b_a_n" : "",
"tax_id" : ""
},
"merchant_order_number" : "000036",
"order_comments" : [],
"order_delivery" : {
"arrived_at" : null,
"collected_at" : null,
"delivery_option_id" : "5fb378e240cfc3002af35205",
"delivery_status" : "pending",
"exp_type" : null,
"name_translations" : {
"en" : "S.F. Express - EF Locker Pickup",
"th" : "",
"zh-hant" : "顺丰快é-顺丰æºè½æ"
},
"platform" : "custom",
"remark" : null,
"request_accepted_at" : null,
"request_authorized_at" : null,
"request_submitted_at" : null,
"requested_fmt_at" : null,
"require_expired_upload" : false,
"require_storeclosed_upload" : false,
"return_order_id" : null,
"returned_at" : null,
"shipped_at" : null,
"status" : "pending",
"store_closed_at" : null,
"storeclosed_upload_at" : null,
"total" : {
"cents" : 500,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 5,
"label" : "HK$5.00"
}
},
"order_discount" : {
"cents" : 0,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 0,
"label" : ""
},
"order_notes" : [],
"order_number" : "000036",
"order_payment" : {
"created_at" : "2021-05-31T03:17:48.047+00:00",
"id" : "60b4555ce02b9b001f421a6e",
"last_four_digits" : "",
"name_translations" : {
"en" : "Cash on Delivery",
"zh-hant" : "貨å°ä»æ¬¾"
},
"paid_at" : null,
"payment_data" : {},
"payment_fee" : {
"cents" : 0,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 0,
"label" : ""
},
"payment_method_id" : "5fcf32781bafc100471ae19c",
"payment_type" : "cash_on_delivery",
"ref_payment_id" : null,
"status" : "temp",
"total" : {
"cents" : 3010,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 30.1,
"label" : "HK$30.10"
},
"updated_at" : "2021-05-31T03:17:48.047+00:00"
},
"order_points" : 200,
"order_points_to_cash" : {
"cents" : 20,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 0.2,
"label" : "HK$0.20"
},
"order_remarks" : null,
"parent_order_id" : "",
"payment_slips" : [],
"promotion_items" : [],
"ref_customer_id" : "test_id",
"ref_order_id" : "",
"skip_fulfillment" : true,
"split_at" : null,
"status" : "pending",
"subtotal" : {
"cents" : 5010,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 50.1,
"label" : "HK$50.10"
},
"subtotal_items" : [
{
"cost" : {
"cents" : 0,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 0,
"label" : ""
},
"created_by" : "admin",
"discounted_price" : null,
"fields_translations" : {},
"id" : "60b4555ce02b9b001f421a6d",
"is_preorder" : false,
"item_data" : {},
"item_id" : "5fd1e2671bafc178701ae195",
"item_price" : {
"cents" : 5010,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 50.1,
"label" : "HK$50.10"
},
"item_type" : "Product",
"item_variation_id" : "",
"item_variation_key" : "",
"media" : {
"_id" : "5fd1e2551bafc178701ae194",
"alt_translations" : {},
"images" : {
"favicon" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"favicon_large" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"favicon_small" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"original" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"source" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"thumb" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"transparent_large" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"transparent_thumb" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
},
"transparent_xlarge" : {
"height" : 1920,
"url" : "https://img-shoplineapp-com.s3.amazonaws.com/media/image_clips/5fd1e2551bafc178701ae194/original.jpg?1607590485",
"width" : 1920
}
}
},
"object_data" : {
"adult" : "no",
"age_group" : "all_ages",
"barcode_type" : "Code 128",
"condition" : "new",
"gender" : "unisex",
"gtin" : "",
"max_order_quantity" : -1,
"mpn" : ""
},
"order_discounted_price" : null,
"price" : {
"cents" : 5010,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 50.1,
"label" : "HK$50.10"
},
"product_subscription_id" : null,
"quantity" : 1,
"ref_data" : null,
"sku" : "",
"title_translations" : {
"en" : "pencil1"
},
"total" : {
"cents" : 5010,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 50.1,
"label" : "HK$50.10"
}
}
],
"system_order_number" : "20210531031747230",
"tags" : [],
"total" : {
"cents" : 3010,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 30.1,
"label" : "HK$30.10"
},
"total_tax_fee" : {
"cents" : 0,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 0,
"label" : ""
},
"updated_at" : "2021-05-31T03:17:48.204+00:00",
"user_credit" : {
"cents" : 0,
"currency_iso" : "HKD",
"currency_symbol" : "HK$",
"dollars" : 0,
"label" : ""
},
"utm_data" : {}
}
FAQ
歷史訂單匯入
Question:
如果要使用 Open API 匯入歷史訂單到 SHOPLINE,商品是否都必須都已經存在商店中,而且訂單的商品價格必須跟商店現行的價格一樣? 如果店家有調整過價格的話,訂單價格跟目前商品價格就不同了,不知道其他的店家是怎麼處理「歷史訂單」的部分?
Answer:
可使用客製商品的方式去匯入訂單總金額就好,不需要一個個品項對應。範例如下,請將 "delivery_option_id"
, "payment_method_id"
,"customer_id"
的 value 改成自己的店對應的 ID。
*使用 Open API 成立(匯入)之歷史訂單無法指定 create time ,預設都會是打 API 當下的時間點。
{
"order": {
"delivery_option_id": "60d5527bfbb7a2001db51c58",
"payment_method_id": "607a596907e0710023fab3ef",
"subtotal": 1000,
"total": 1000,
"items":[
{
"item_type":"CustomProduct",
"item_price": 1000,
"item_data": {
"name": "歷史訂單-商品A",
"price": "1000"
},
"quantity": 1, "total": 1000 }
],
"customer_id": "637df825f47cba000c2c19d4",
"delivery_address": {
"city": "台北市",
"postcode": "10560",
"address_2": "松山區",
"address_1": "光復北路11巷44號14樓",
"recipient_name": "收件人",
"recipient_phone": "0227423966",
"country": "台灣",
"country_code": "TW"
}
}
}
匯入後的訂單在後台呈現:
"item_data" 的 "name" 可以任意命名
匯入後前台會員中心呈現:
Updated 26 days ago