Create Order
NoticeWithout 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 |
| ID of Delivery Option
| |
order.payment_method_id |
| ID of Payment Option
| |
order.subtotal |
| Price Total for all order items | |
order.total |
| Final price total, including credits and discounts deducted.
| |
order.items |
| Order product Item Data [Note]
| |
order.customer_id |
| Customer ID | |
order.customer_email |
| Customer's Email | |
order.customer_phone |
| Customer's Phone | |
order.delivery_address | Delivery Address Information | | |
order.order_remarks | String | Add order remark to the order, cannot be updated via patch | |
order.user_credit |
| Credits used for the order | |
order.opt_in_auto_reward | 'Boolean' | Apply "Order Reward Credits" and “Reward Campaign” automatically [Note]
|
|
member_point |
| Applied Member Point |
|
is_registering_as_member |
| Do you want to set the customer as a member?
| |
is_inventory_fulfillment |
| Do you want to deduct the inventory numbers after the order is created?
| |
mail_notify |
| Do you want to notify the customer of the order creation by email ?
| |
。
*出貨方式/付款方式的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。
因物流名稱、金流名稱會顯示在 ADMIN 後台與客戶視角的訂單呈現,建議可以另行新增自訂物流方式與自訂付款方式進行訂單匯入
*使用 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 13 days ago