【问题标题】:Shopify products/delete webhook only returns IDShopify 产品/删除 webhook 仅返回 ID
【发布时间】:2021-07-23 01:44:52
【问题描述】:

每当删除产品时,我的 ruby​​ on rails 应用程序都应该做一些事情。根据Shopify's website here,对products/delete 的响应应该是一个JSON 对象,其中包含与已删除产品相关联的product_id 等信息:

{
  "id": 788032119674292922,
  "title": "Example T-Shirt",
  "body_html": null,
  "vendor": "Acme",
  "product_type": "Shirts",
  "created_at": null,
  "handle": "example-t-shirt",
  "updated_at": "2021-07-01T14:08:43-04:00",
  "published_at": "2021-07-01T14:08:43-04:00",
  "template_suffix": null,
  "published_scope": "web",
  "tags": "example, mens, t-shirt",
  "admin_graphql_api_id": "gid:\/\/shopify\/Product\/788032119674292922",
  "variants": [
    {
      "id": 642667041472713922,
      "product_id": 788032119674292922,
      "title": "",
      "price": "19.99",
      "sku": "example-shirt-s",
      "position": 0,
      "inventory_policy": "deny",
      "compare_at_price": "24.99",
      "fulfillment_service": "manual",
      "inventory_management": "shopify",
      "option1": "Small",
      "option2": null,
      "option3": null,
      "created_at": null,
      "updated_at": null,
      "taxable": true,
      "barcode": null,
      "grams": 200,
      "image_id": null,
      "weight": 200.0,
      "weight_unit": "g",
      "inventory_item_id": null,
      "inventory_quantity": 75,
      "old_inventory_quantity": 75,
      "requires_shipping": true,
      "admin_graphql_api_id": "gid:\/\/shopify\/ProductVariant\/642667041472713922"
    },
    {
      "id": 757650484644203962,
      "product_id": 788032119674292922,
      "title": "",
      "price": "19.99",
      "sku": "example-shirt-m",
      "position": 0,
      "inventory_policy": "deny",
      "compare_at_price": "24.99",
      "fulfillment_service": "manual",
      "inventory_management": "shopify",
      "option1": "Medium",
      "option2": null,
      "option3": null,
      "created_at": null,
      "updated_at": null,
      "taxable": true,
      "barcode": null,
      "grams": 200,
      "image_id": null,
      "weight": 200.0,
      "weight_unit": "g",
      "inventory_item_id": null,
      "inventory_quantity": 50,
      "old_inventory_quantity": 50,
      "requires_shipping": true,
      "admin_graphql_api_id": "gid:\/\/shopify\/ProductVariant\/757650484644203962"
    }
  ],
  "options": [
    {
      "id": 527050010214937811,
      "product_id": 788032119674292922,
      "name": "Title",
      "position": 1,
      "values": [
        "Small",
        "Medium"
      ]
    }
  ],
  "images": [
    {
      "id": 539438707724640965,
      "product_id": 788032119674292922,
      "position": 0,
      "created_at": null,
      "updated_at": null,
      "alt": null,
      "width": 323,
      "height": 434,
      "src": "\/\/cdn.shopify.com\/shopifycloud\/shopify\/assets\/shopify_shirt-39bb555874ecaeed0a1170417d58bbcf792f7ceb56acfe758384f788710ba635.png",
      "variant_ids": [
      ],
      "admin_graphql_api_id": "gid:\/\/shopify\/ProductImage\/539438707724640965"
    }
  ],
  "image": null
}

但是,每当我通过在 Shopify 管理界面中实际删除产品来测试它时,我的回复中只会收到 id。有人知道为什么会这样吗?我对其他 webhook 的设置完全相同,没有任何其他问题。

【问题讨论】:

    标签: ruby-on-rails shopify shopify-app


    【解决方案1】:

    似乎这是 shopify_api gem 上的open issue 版本2021-01。我不认为你做错了什么。似乎有一段时间没有人对此问题做出回应,您可能想尝试升级到 another version,看看他们是否在任何较新的版本中修复了它。

    编辑:根据 3/2017 的 post,已删除端点的预期行为是仅返回已删除资源的 ID。这可能是 Github 上的问题被忽略的原因。

    【讨论】:

    • 我使用的是 2021-04 版本。我想仍然是一个问题:(...我会尝试更高版本的 API
    • 我对此进行了更深入的研究,在 2017 年 community.shopify.com/c/Shopify-APIs-SDKs/… 的这篇帖子中,Shopify 的一名员工表示,只返回一个 id 是预期的行为。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-16
    • 1970-01-01
    • 2021-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多