当程序尝试发布已存在的货件时,BigCommerce 能否更改其 API 响应以使其更加清晰?
将货件发布到 BigCommerce 时,如果货件已存在,您会收到以下错误消息。
<?xml version="1.0"?>
<errors>
<error>
<status>400</status>
<message>The field 'quantity' is invalid.</message>
<details>
<invalid_reason>The quantity specified is greater than the quantity of the product that is available to ship.</invalid_reason>
<available_quantity>0</available_quantity>
<order_product_id>628</order_product_id>
</details>
</error>
</errors>
我同意这是一个错误的要求,但这与商品的数量无关。我们可以对 message
或 invalid_reason
执行类似以下操作吗?
The shipment [insert ID here] already exists and cannot be added.
这将使 API 更加可用。
最佳答案
查询订单产品资源时,有可用的发货数量,当您创建发货时,可用数量会减少到 0。
最初,发货 POST 成功,因为有效负载中指定的数量与订单的数量匹配。如果您要将发货发布到已发货的订单,则可用数量实际上为 0,并且当您在有效负载中为数量指定正整数时,该数量无效且大于可用数量,因此错误是准确的.
关于api - BigCommerce 的回应更加明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17886266/