1

我正在尝试创建具有多个变体和选项的产品。我在 shopify api 文档中使用了示例 json。但它给了我一个错误。好像例子错了?

require_once("inc/functions.php");
$shop = "abc";
setGlobalVariables( $shop) ;


$product_json = '{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!</strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
      {
        "option1": "Blue",
        "option2": "155"
      },
      {
        "option1": "Black",
        "option2": "159"
      }
    ],
    "options": [
      {
        "name": "Color",
        "values": [
          "Blue",
          "Black"
        ]
      },
      {
        "name": "Size",
        "values": [
          "155",
          "159"
        ]
      }
    ]
  }
}';

$products_array=json_decode($product_json, true);

$modified_product = shopify_call($token, $shop, "/admin/api/".$shopifyVer."/products.json",$products_array,'POST');
$modified_product_response = $modified_product['response'];



echo "<pre>";
print_r($modified_product_response);
echo "</pre>";

echo "Successfully Inserted.";

这是我使用的代码。希望有人可以帮助我。谢谢!

4

0 回答 0