Magento REST API跟踪号未更新



我正在使用Magento 2.2.2版本。我正在尝试通过他们的休息 API 更新跟踪信息。这是我的代码:

$tracking_str   =   
        '{
         "items": [
            {
              "extension_attributes": {},
              "order_item_id": "'.$orderItemId.'",
              "qty": "'.$qty_invoiced.'"
            }
          ],
          "notify": false,
          "appendComment": true,
          "comment": {
            "extension_attributes": {},
            "comment": "Item(s) has been shipped",
            "is_visible_on_front": 0
          },
          "tracks": [
            {
              "extension_attributes": {},
              "track_number": "'.$TrackingNumber.'",
              "title": "'.$ShipTitle.'",
              "carrier_code": "'.$carrierCode.'"
            }
          ],
          "packages": [
            {
              "extension_attributes": {}
            }
          ],
          "arguments": {
            "extension_attributes": {}
          }
        }';

我正在将上述内容传递给php curl,并且第一次收到货件ID的响应。订单状态正在通过Magento API更改为"完成"。但是,承运人代码和跟踪号等跟踪信息不会更新。当我再次运行代码时,我得到的响应为:

 res is: stdClass Object
(    [message] => Shipment Document Validation Error(s):
The order does not allow a shipment to be created.
You can't create a shipment without products.
)

我不知道,我哪里出错了。

终于成功了!!

$tracking_str = [ "items"=> [ [ "order_item_id"=>$orderItemId, "qty"=> $qty_invoiced ] ], "notify" => true, "appendComment" => true, "comment" => [ "extension_attributes" => [], "comment" => "Item(s) has been shipped", "is_visible_on_front" => 0 ], "tracks" => [ [ "extension_attributes" => [], "track_number" => $TrackingNumber, "title" => $ShipTitle, "carrier_code" => $carrierCode ] ] ]

上面的代码,我已经用过了。 GitHub论坛中的某个人帮助了我。多亏了他们。现在正在更新跟踪号,运营商代码和标题。

这个解决方案对我有用。

{
  "appendComment": true,
  "notify": true,
  "comment": {
    "comment": "shipment creado via webservice",
    "is_visible_on_front": 1
  },
  "tracks": [
    {
      "track_number": "3SCEMW182389201",
      "title": "UPS",
      "carrier_code": "Carrier code n"
    }
  ]
}

删除项目。

最新更新