不需要 Shopify webhooks

Shopify webhooks not wanted

我正在使用 API 和 Webhook 将我的网站连接到 Shopify。当我在我的网站上创建产品时,我希望它是在 Shopify 上创建的。这样可行。但是 Shopify 发回一个 Webhook 告诉我已经创建了一个产品:所以它在我的网站上创建了相同的产品......我也希望以其他方式创建产品。

我无法使用 Shopify 产品 ID 检查该产品是否已存在于我的网站上,因为我还没有收到它。

我觉得我可能会找到一种方法让它工作,但我不确定这是否是最干净的方法。我想知道这种情况的最佳解决方案是什么。

编辑:(添加当前想法)

是否有办法让 Shopify 在我创建产品时不要将 webhook 发回给我?

编辑 2: 其他想法:

第一个:
您在您的网站上创建新产品: 使用 api 你也 create it on your shopify store

//sample
POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestlye 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "images": [
      {
        "src": "http:\/\/example.com\/rails_logo.gif"
      }
    ]
  }
}

shopify 同时回复:

"product": {
    "id": 1071559589,
    "title": "Burton Custom Freestlye 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "created_at": "2015-12-08T11:42:18-05:00",
    "handle": "burton-custom-freestlye-151",
    "updated_at": "2015-12-08T11:42:18-05:00",
    "published_at": "2015-12-08T11:42:18-05:00",
    "template_suffix": null,
    "published_scope": "global",
    "tags": "",
    "variants": [
      {
        "id": 1070325044,
        "product_id": 1071559589,
        "title": "Default Title",
        "price": "0.00",
        "sku": "",
        "position": 1,
        "grams": 0,
        "inventory_policy": "deny",
        "compare_at_price": null,
        "fulfillment_service": "manual",
        "inventory_management": null,
        "option1": "Default Title",
        "option2": null,
        "option3": null,
        "created_at": "2015-12-08T11:42:18-05:00",
        "updated_at": "2015-12-08T11:42:18-05:00",
        "requires_shipping": true,
        "taxable": true,
        "barcode": null,
        "inventory_quantity": 1,
        "old_inventory_quantity": 1,
        "image_id": null,
        "weight": 0.0,
        "weight_unit": "kg"
      }
    ],
    ...
    ..
    .
    .

第二个:
然后您创建了产品数据,您可以将 id 保存在产品 table 网站的一列中,以使用 shopify 的 webhook 进行验证。
简单!