【问题标题】:Unable to update product using SHOPIFY PHP API无法使用 SHOPIFY PHP API 更新产品
【发布时间】:2012-11-02 06:22:50
【问题描述】:

我正在实施 @sandeep shetty shopify api 将记录插入我的 shopify 商店。我已经完全实现了插入,并且在我的商店中运行良好。我在更新过程中遇到问题。我无法更新正在插入商店的记录。我正在根据插入后由 api 生成的 id 更新记录。
这是我为更新产品编写的代码。

将在shopify api调用中作为参数传递的数组。

$product = array
    (

        "product" => array
        (
            "variants" => array
                (
                    "price" =>  $cat['selling_price'],
                    "inventory_quantity"=>($cat['original_qty']!="") ? $cat['original_qty'] : 'Null',
                )
        )
    );

更新产品的代码。

$update = $shopify('PUT', "/admin/products/#{id}.json", $product); 

【问题讨论】:

  • 我继续删除了我的答案。所以我假设 $shopify 方法正在替换 {id}?因为 #{id} 是伪代码。您收到了哪些错误消息?

标签: php api shopify


【解决方案1】:

我曾经在 json 数据中提供 ID。我使用的代码:

$data_string = '
{
    "variant": {
        "id": "'.$idVar.'",
        "option1": "'.$this->input->post('variant').'",
        "price": "'.$this->input->post('salesPrice').'",
        "inventory_quantity": "'.$this->input->post('stockQty').'"
    }
}
';

要更新变体,我使用以下网址:

/admin/variants/".$idVar.".json"

另外,使用 000000000.json,去掉 # 符号。

【讨论】:

  • 真的很不错,更新数量也很方便
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-04
  • 2015-04-04
  • 1970-01-01
  • 2020-06-14
  • 2020-01-13
  • 1970-01-01
相关资源
最近更新 更多