简体   繁体   English

如何为通过 API 订购的 shopware 6 更新或添加跟踪代码?

[英]How to update or add tracking codes to shopware 6 order via API?

I want to update or add tracking codes to orders in shopware, the same way that it is done in the admin panel via the API. Admin panel field to add or update tracking codes我想为 shopware 中的订单更新或添加跟踪代码,方法与通过 API 在管理面板中完成的方式相同。用于添加或更新跟踪代码的管理面板字段

First Try I first tried copying the payload used by the admin panel Payload of the admin panel I got this error error from copied payload Second Try 2. I tried using the patch method from the documentation Patch Request I got this error error in the admin panel一次尝试首先尝试复制管理面板使用的有效载荷

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET https://(domain)/69d9897fb4db7b7c9c28.worker.js.map"" at /home/schcmjkg/staging/vendor/symfony/http-kernel/EventListener/RouterListener.php line 135 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): No route found for "GET https://(domain)/69d9897fb4db7b7c9c28.worker.js.map" at /home/schcmjkg/staging/vendor/symfony/http-kernel/EventListener/RouterListener.php:135)\n[previous exception] [object] (Symfony\Component\Routing\Exception\ResourceNotFoundException(code: 0): No routes found for "/69d9897fb4db7b7c9c28.worker.js.map/". at /home/schcmjkg/staging/vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherTrait.php:74)"} [] request.ERROR:未捕获 PHP 异常 Symfony\Component\HttpKernel\Exception\NotFoundHttpException:“在 /home/schcmjkg/staging/vendor 找不到“GET https://(domain)/69d9897fb4db7b7c9c28.worker.js.map”的路由” /symfony/http-kernel/EventListener/RouterListener.php 行 135 {“异常”:“对象](Symfony\Component\HttpKernel\Exception\NotFoundHttpException(代码:0):找不到“GET https://( domain)/69d9897fb4db7b7c9c28.worker.js.map" 在 /home/schcmjkg/staging/vendor/symfony/http-kernel/EventListener/RouterListener.php:135)\n[previous exception] [object] (Symfony\Component\Routing \Exception\ResourceNotFoundException(代码:0):找不到“/69d9897fb4db7b7c9c28.worker.js.map/”的路由。在/home/schcmjkg/staging/vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherTrait.php:74) “} []

But the tracking codes were added everytime(not updated), which gave the error i presume.但是每次都添加了跟踪代码(未更新),这给出了我认为的错误。 enter image description here I could add the other images but bascically te-he same order ended up with different tracking codes with same shipping ids在此处输入图片描述我可以添加其他图片,但基本上相同的订单最终会以不同的跟踪代码和相同的运输 ID 结束

First you'll have to fetch the id of the order_delivery associated with the order.首先,您必须获取与订单关联的order_delivery的 ID。

GET /api/order/{orderId}?associations[deliveries][]&includes[order][]=deliveries&includes[order_delivery][]=id

Response example:响应示例:

{
    "data": {
        "deliveries": [
            {
                "id": "9d1994d328b44f3e941c9484415ec95c",
                "apiAlias": "order_delivery"
            }
        ],
        "apiAlias": "order"
    }
}

Take the id from the response and use it to update the order_delivery record.从响应中获取 id 并使用它来更新order_delivery记录。

PATCH /api/order-delivery/9d1994d328b44f3e941c9484415ec95c

Request body:请求正文:

{
  "trackingCodes": ["foobar"]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM