我发送此请求:
{ "carrier_service":
{ "name": "Test Provider",
"callback_url": "callback_url",
"format": "json",
"service_discovery": true,
"rate": {
"origin": {
"country": "CA",
"postal_code": "K1S4J3",
"province": "ON",
"city": "Ottawa",
"name": "test name",
"address1": "520 Cambridge Street South",
"address2": "asas",
"address3": "sdsdsd",
"phone": "32323323434",
"fax": "3434343434",
"address_type": "sdsdsd",
"company_name": "test"
},
"destination": {
"country": "CA",
"postal_code": "K1S 3T7",
"province": "ON",
"city": "Ottawa",
"name": "Jason Normore",
"address1": "520 Cambridge Street South Apt. 5",
"address2": null,
"address3": null,
"phone": "7097433959",
"fax": null,
"address_type": null,
"company_name": null
},
"items": [
{
"name": "My Product 3",
"sku": "sdsdsdsd",
"quantity": 1,
"grams": 1000,
"price": 2000,
"vendor": "TestVendor",
"requires_shipping": true,
"taxable": true,
"fulfillment_service": "manual"
}
],
"currency": "CAD"
}
}
}
它的说法 你已经为这家商店设置了测试提供商 但是,当我删除运营商并再次提出请求时,它只显示
{"carrier_services":[{"active":true,"id":116379,"name":"Test Provider","service_discovery":true,"carrier_service_type":"api"}]}
但我需要得到像http://docs.shopify.com/api/carrierservice
所述的回复{
"rates": [
{
"service_name": "canadapost-overnight",
"service_code": "ON",
"total_price": "1295",
"currency": "CAD",
"min_delivery_date": "2013-04-12 14:48:45 -0400",
"max_delivery_date": "2013-04-12 14:48:45 -0400"
},
{
"service_name": "fedex-2dayground",
"service_code": "1D",
"total_price": "2934",
"currency": "USD",
"min_delivery_date": "2013-04-12 14:48:45 -0400",
"max_delivery_date": "2013-04-12 14:48:45 -0400"
},
{
"service_name": "fedex-2dayground",
"service_code": "1D",
"total_price": "2934",
"currency": "USD",
"min_delivery_date": "2013-04-12 14:48:45 -0400",
"max_delivery_date": "2013-04-12 14:48:45 -0400"
}
]
}
答案 0 :(得分:1)
为CarrierService API文档另外阅读。
此部分用于设置您的运营商服务;通常在商家安装您的应用时:
https://help.shopify.com/api/reference/carrierservice#create
然后,假设商店拥有CarrierServices API权限,Shopify会在客户结账时向您发送以下内容:
{
"rate": {
"origin": {
"country": "CA",
"postal_code": "K1S4J3",
"province": "ON",
"city": "Ottawa",
"name": null,
"address1": "520 Cambridge Street South",
"address2": null,
"address3": null,
"phone": null,
"fax": null,
"address_type": null,
"company_name": null
},
"destination": {
"country": "CA",
"postal_code": "K1S 3T7",
"province": "ON",
"city": "Ottawa",
"name": "Jason Normore",
"address1": "520 Cambridge Street South Apt. 5",
"address2": null,
"address3": null,
"phone": "7097433959",
"fax": null,
"address_type": null,
"company_name": null
},
"items": [
{
"name": "My Product 3",
"sku": null,
"quantity": 1,
"grams": 1000,
"price": 2000,
"vendor": "TestVendor",
"requires_shipping": true,
"taxable": true,
"fulfillment_service": "manual"
}
],
"currency": "CAD"
}
}
请注意,它不是常规的_POST,而是一个流 - 您可以通过以下方式访问PHP:
file_get_contents('php://input');
..你用这个来计算你的费率,然后按以下格式返回:
{
"rates": [
{
"service_name": "canadapost-overnight",
"service_code": "ON",
"total_price": "1295",
"currency": "CAD",
"min_delivery_date": "2013-04-12 14:48:45 -0400",
"max_delivery_date": "2013-04-12 14:48:45 -0400"
},
{
"service_name": "fedex-2dayground",
"service_code": "2D",
"total_price": "2934",
"currency": "USD",
"min_delivery_date": "2013-04-12 14:48:45 -0400",
"max_delivery_date": "2013-04-12 14:48:45 -0400"
},
{
"service_name": "fedex-priorityovernight",
"service_code": "1D",
"total_price": "3587",
"currency": "USD",
"min_delivery_date": "2013-04-12 14:48:45 -0400",
"max_delivery_date": "2013-04-12 14:48:45 -0400"
}
]
}
..只要结帐时间没有超时,客户就会看到退回的费率。