我在为带有文字选项的产品创建bigcommerce订单时遇到问题,api会出现以下错误:
[
{
"status": 400,
"message": "The options of one or more products are invalid.",
"details": {
"errors": [
{
"type": "InvalidProductOptionValue",
"product": {
"id": 3190,
"name": "Esprit Knit Tech Gloves.",
"product_option": {
"id": 445,
"option_id": 47,
"display_name": "Name To Print",
"value": "moni test",
"url": "https:\/\/api.bigcommerce.com\/stores\/xxxxxx\/v2\/products\/3190\/options\/445",
"resource": "\/products\/3190\/options\/445"
},
"url": "https:\/\/api.bigcommerce.com\/stores\/xxxxxx\/v2\/products\/3190",
"resource": "\/products\/3190"
}
}
]
}
}
]
我发送的产品对象是:
[
{
"product_id":"3190",
"quantity":1,
"product_options":[
{
"id":"445",
"value":"TEXT option"
}
]
}
]
使用的代码适用于带有下拉选项的产品。我不知道还有什么要发送,我无法在他们的文档中找到答案。
答案 0 :(得分:3)
我们收到了bigcommerce的回复,称在创建订单时API不支持TEXT选项。
这是他们的答案: "我知道您正在尝试使用文本字段作为选项创建订单。不幸的是,这种类型的产品选项对象是不可能的。对象的value属性只接受整数(基于选项的选项值的id)。"
答案 1 :(得分:0)
必须检查选项是否存在?。
bigcommerce错误400说:发送格式错误的请求时发出。如由于语法无效或缺少所需数据。注意:Webhook请求在HTTP标头中缺少Content-Type将返回400。
在文档中说'product_options'并且您输入'product_option'
我认为应该如此:
"product": {
"id": 3190,
"name": "Esprit Knit Tech Gloves.",
"product_options": [{
"id": 445,
"option_id": 47,
"display_name": "Name To Print",
"value": "moni test",
"url": "https:\/\/api.bigcommerce.com\/stores\/xxxxxx\/v2\/products\/3190\/options\/445",
"resource": "\/products\/3190\/options\/445"
}],
"url": "https:\/\/api.bigcommerce.com\/stores\/xxxxxx\/v2\/products\/3190",
"resource": "\/products\/3190"
}
例如: 如果您的产品有两个具有多个值的选项,那么您必须设置两个选项值组合,并且它们的库存水平> 0:
产品ID为49且选项为:
Array
(
[0] => stdClass Object
(
[id] => 105
[option_id] => 18
[display_name] => Size
[sort_order] => 0
[is_required] => 1
)
[1] => stdClass Object
(
[id] => 106
[option_id] => 3
[display_name] => Color
[sort_order] => 1
[is_required] => 1
)
)
选项1:
Array
(
[0] => stdClass Object
(
[id] => 68
[option_id] => 18
[label] => XS
[sort_order] => 0
[value] => XS
)
[1] => stdClass Object
(
[id] => 69
[option_id] => 18
[label] => S
[sort_order] => 1
[value] => S
)
[2] => stdClass Object
(
[id] => 70
[option_id] => 18
[label] => M
[sort_order] => 2
[value] => M
)
[3] => stdClass Object
(
[id] => 71
[option_id] => 18
[label] => L
[sort_order] => 3
[value] => L
)
[4] => stdClass Object
(
[id] => 72
[option_id] => 18
[label] => XL
[sort_order] => 4
[value] => XL
)
)
选项2:
Array
(
[0] => stdClass Object
(
[id] => 7
[option_id] => 3
[label] => Silver
[sort_order] => 1
[value] => #cccccc
)
[1] => stdClass Object
(
[id] => 8
[option_id] => 3
[label] => Black
[sort_order] => 2
[value] => #000000
)
[2] => stdClass Object
(
[id] => 9
[option_id] => 3
[label] => Purple
[sort_order] => 3
[value] => #700170
)
[3] => stdClass Object
(
[id] => 10
[option_id] => 3
[label] => Blue
[sort_order] => 4
[value] => #123c91
)
[4] => stdClass Object
(
[id] => 11
[option_id] => 3
[label] => Green
[sort_order] => 5
[value] => #0f961e
)
[5] => stdClass Object
(
[id] => 12
[option_id] => 3
[label] => Yellow
[sort_order] => 6
[value] => #f0f005
)
[6] => stdClass Object
(
[id] => 13
[option_id] => 3
[label] => Orange
[sort_order] => 7
[value] => #e35e20
)
[7] => stdClass Object
(
[id] => 14
[option_id] => 3
[label] => Pink
[sort_order] => 9
[value] => #e841c1
)
[8] => stdClass Object
(
[id] => 39
[option_id] => 3
[label] => Red
[sort_order] => 8
[value] => #e60c0c
)
)
简单的订单示例:
array(
"customer_id"=> 0,
"status_id"=> 1,
"base_shipping_cost"=> 0,
"base_handling_cost"=> 0,
"refunded_amount"=> 0,
"order_is_digital"=> false,
"staff_notes"=> "",
"customer_message"=> "",
"discount_amount"=> 10,
"billing_address"=> array(
"first_name"=> "Trisha",
"last_name"=> "McLaughlin",
"company"=> "",
"street_1"=> "12345 W Anderson Ln",
"street_2"=> "",
"city"=> "Austin",
"state"=> "Texas",
"zip"=> "78757",
"country"=> "United States",
"country_iso2"=> "US",
"phone"=> "",
"email"=> "elsie@example.com"
),
"products"=> array(
array(
"product_id" => 49,
"quantity" => 1,
"product_options"=> array(
array(
"id" => 105,//product option id
"value"=> 68 //option value id
),
array(
"id" => 106,//product option id
"value"=> 7 //option value id
)
)
)
)
));
响应:
object(stdClass)[10]
public 'id' => int 24
public 'customer_id' => int 0
public 'date_created' => string 'Wed, 04 Mar 2015 16:55:54 +0000' (length=31)
public 'date_modified' => string 'Wed, 04 Mar 2015 16:55:54 +0000' (length=31)
public 'date_shipped' => string '' (length=0)
public 'status_id' => int 1
public 'status' => string 'Pending' (length=7)
public 'subtotal_ex_tax' => string '90.0000' (length=7)
public 'subtotal_inc_tax' => string '90.0000' (length=7)
public 'subtotal_tax' => string '0.0000' (length=6)
public 'base_shipping_cost' => string '0.0000' (length=6)
public 'shipping_cost_ex_tax' => string '0.0000' (length=6)
public 'shipping_cost_inc_tax' => string '0.0000' (length=6)
public 'shipping_cost_tax' => string '0.0000' (length=6)
public 'shipping_cost_tax_class_id' => int 0
public 'base_handling_cost' => string '0.0000' (length=6)
public 'handling_cost_ex_tax' => string '0.0000' (length=6)
public 'handling_cost_inc_tax' => string '0.0000' (length=6)
public 'handling_cost_tax' => string '0.0000' (length=6)
public 'handling_cost_tax_class_id' => int 0
public 'base_wrapping_cost' => string '0.0000' (length=6)
public 'wrapping_cost_ex_tax' => string '0.0000' (length=6)
public 'wrapping_cost_inc_tax' => string '0.0000' (length=6)
public 'wrapping_cost_tax' => string '0.0000' (length=6)
public 'wrapping_cost_tax_class_id' => int 0
public 'total_ex_tax' => string '80.0000' (length=7)
public 'total_inc_tax' => string '80.0000' (length=7)
public 'total_tax' => string '0.0000' (length=6)
public 'items_total' => int 1
public 'items_shipped' => int 0
public 'payment_method' => string 'Manual' (length=6)
public 'payment_provider_id' => null
public 'payment_status' => string '' (length=0)
public 'refunded_amount' => string '0.0000' (length=6)
public 'order_is_digital' => boolean false
public 'store_credit_amount' => string '0.0000' (length=6)
public 'gift_certificate_amount' => string '0.0000' (length=6)
public 'ip_address' => string '' (length=0)
public 'geoip_country' => string '' (length=0)
public 'geoip_country_iso2' => string '' (length=0)
public 'currency_id' => int 1
public 'currency_code' => string 'USD' (length=3)
public 'currency_exchange_rate' => string '1.0000000000' (length=12)
public 'default_currency_id' => int 1
public 'default_currency_code' => string 'USD' (length=3)
public 'staff_notes' => string '' (length=0)
public 'customer_message' => string '' (length=0)
public 'discount_amount' => string '10.0000' (length=7)
public 'coupon_discount' => string '0.0000' (length=6)
public 'shipping_address_count' => int 1
public 'is_deleted' => boolean false
public 'ebay_order_id' => string '0' (length=1)
public 'billing_address' =>
object(stdClass)[11]
public 'first_name' => string 'Trisha' (length=6)
public 'last_name' => string 'McLaughlin' (length=10)
public 'company' => string '' (length=0)
public 'street_1' => string '12345 W Anderson Ln' (length=19)
public 'street_2' => string '' (length=0)
public 'city' => string 'Austin' (length=6)
public 'state' => string 'Texas' (length=5)
public 'zip' => string '78757' (length=5)
public 'country' => string 'United States' (length=13)
public 'country_iso2' => string 'US' (length=2)
public 'phone' => string '' (length=0)
public 'email' => string 'elsie@example.com' (length=17)
public 'order_source' => string 'external' (length=8)
public 'external_source' => null
public 'products' =>
object(stdClass)[12]
public 'url' => string 'https://store-qq6db7r.mybigcommerce.com/api/v2/orders/24/products.json' (length=70)
public 'resource' => string '/orders/24/products' (length=19)
public 'shipping_addresses' =>
object(stdClass)[13]
public 'url' => string 'https://store-qq6db7r.mybigcommerce.com/api/v2/orders/24/shippingaddresses.json' (length=79)
public 'resource' => string '/orders/24/shippingaddresses' (length=28)
public 'coupons' =>
object(stdClass)[14]
public 'url' => string 'https://store-qq6db7r.mybigcommerce.com/api/v2/orders/24/coupons.json' (length=69)
public 'resource' => string '/orders/24/coupons' (length=18)