尝试在 Shopify 中添加变体时出错

     2023-02-16     219

关键词:

【中文标题】尝试在 Shopify 中添加变体时出错【英文标题】:Error when trying to add a variant in Shopify 【发布时间】:2017-02-08 13:42:27 【问题描述】:

我正在尝试向现有产品 ID 添加一个变体。 下面是我完成的 JSON 请求。但是我得到一个错误

"errors":"variant":"expected Array to be a Hash" 

JSON 请求。

"variant": ["product_id": 10065509898,"title": "XS\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_XS","position": 1,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "XS","option3": null,"taxable": true,"barcode": "800123054849","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true,"product_id": 10065509898,"title": "S\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_S","position": 2,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "S","option3": null,"taxable": true,"barcode": "800123054856","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true,"product_id": 10065509898,"title": "M\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_M","position": 3,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "M","option3": null,"taxable": true,"barcode": "800123054863","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true,"product_id": 10065509898,"title": "L\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_L","position": 4,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "L","option3": null,"taxable": true,"barcode": "800123054870","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true,"product_id": 10065509898,"title": "XL\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_XL","position": 5,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "XL","option3": null,"taxable": true,"barcode": "800123054887","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true,"product_id": 10065509898,"title": "XXL\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_XXL","position": 6,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "XXL","option3": null,"taxable": true,"barcode": "800123054894","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true]

我做错了什么?

【问题讨论】:

您在哪个 URL 上进行 RESTful 调用?是 PUT 还是 POST?产品中是否已经存在任何变体? 【参考方案1】:

这是因为您要发送一系列变体。您必须单独add each variant:

POST /admin/products/product_id/variants.json


    "variant": 
        "option1": "BROWN",
        "price": "49.05",
        "sku": "BA1015_BROWN_XS"
     

只有当你是creating a new product时,你才能传递一个变体数组。

【讨论】:

您还可以在产品上使用“PUT”添加多个变体。 @HymnZ 要小心,因为它会替换现有的变体。 不。如果您在数组中提供变体 ID,则可以将现有变体与新变体一起保留。一个漂亮的隐藏功能..

Shopify 主题开发 |从选择列表中选择不同的产品变体时更新价格

】Shopify主题开发|从选择列表中选择不同的产品变体时更新价格【英文标题】:ShopifyThemeDevelopment|Updatingpricewhendifferentproductvariantischosenfromselectlist【发布时间】:2020-02-2017:51:00【问题描述】:当从其他产品选项的选择下拉列表中... 查看详情

Shopify 在选择变体时触发功能,但不会覆盖现有功能

】Shopify在选择变体时触发功能,但不会覆盖现有功能【英文标题】:Shopifytriggerfunctiononvariantselectionbutdon\'toverrideexistingfunctionality【发布时间】:2019-11-1023:20:58【问题描述】:我在Shopify上使用“阁楼”主题。当我在产品页面上选... 查看详情

在 Shopify 中添加自定义多图像部分

】在Shopify中添加自定义多图像部分【英文标题】:Addcustommulti-imagesectioninShopify【发布时间】:2019-12-1309:29:51【问题描述】:我正在尝试在Shopify中添加一个自定义部分,以允许用户上传2张宣传图片。我是新手,但我设法为1张图... 查看详情

使用 Shopify 在 Collection 页面上筛选变体

】使用Shopify在Collection页面上筛选变体【英文标题】:VariantfilteronCollectionpageswithShopify【发布时间】:2017-12-2223:22:28【问题描述】:我正在尝试在我的收藏页面中设置过滤器。到目前为止,我设法设置了一个很棒的自定义标签过... 查看详情

Shopify:如何显示每个位置变体的库存数量?

】Shopify:如何显示每个位置变体的库存数量?【英文标题】:Shopify:Howtodisplayinventoryquantitiesofavariantperlocation?【发布时间】:2020-08-2408:00:11【问题描述】:是否可以在产品页面上显示每个位置的产品变型的库存数量?由于此信息... 查看详情

Shopify - 通过多个变体 ID 检索多个变体详细信息

】Shopify-通过多个变体ID检索多个变体详细信息【英文标题】:Shopify-Retrievesmultiplevariantdetailbymultiplevariantid【发布时间】:2019-05-0309:02:37【问题描述】:有没有办法在单个shopify调用中使用多个变体ID获取多个变体详细信息。实际... 查看详情

Shopify 变体价格现在正确显示

】Shopify变体价格现在正确显示【英文标题】:ShopifyVariantPriceNowShowingCorrectly【发布时间】:2020-03-0909:54:06【问题描述】:这看起来很简单,但无论出于何种原因,我都看不到森林中的树木。所以我在屏幕截图1中看到了当前情况... 查看详情

使用布鲁克林主题在 Shopify 的收藏页面上显示所有颜色变体

】使用布鲁克林主题在Shopify的收藏页面上显示所有颜色变体【英文标题】:ShowAllColorVariantsonCollectionpageinShopifyusing***lynTheme【发布时间】:2016-05-1509:28:20【问题描述】:嘿,我在我的shopify网站上使用***lyn主题。我有不同的产品会... 查看详情

尝试在 Julia 中添加 BlossomV 包时出错

】尝试在Julia中添加BlossomV包时出错【英文标题】:ErrorwhiletryingtoaddBlossomVpackageinJulia【发布时间】:2021-12-1701:09:49【问题描述】:我正在尝试在Julia中添加BlossomV包。我收到以下错误:*LoadError:BlossomVnotproperlyinstalled.PleaserunPkg.Build("... 查看详情

Shopify- 获取属性形式 <select>

】Shopify-获取属性形式<select>【英文标题】:Shopify-gettingattributeform<select>【发布时间】:2021-10-0522:28:33【问题描述】:所以我有一个问题。我正在Sopify中开发一家商店,并且我有一个自定义部分,其中我有用于选择变体... 查看详情

尝试将私有密钥添加到 AWS Opsworks 时出错

】尝试将私有密钥添加到AWSOpsworks时出错【英文标题】:ErrorontryingtoaddPrivatekeytoAWSOpsworks【发布时间】:2020-05-2022:49:27【问题描述】:我正在尝试在AWSOpswork上设置一个新的rails应用程序。在尝试添加新应用时,我不断收到错误消... 查看详情

Shopify - 将尺寸变体从选择下拉菜单更改为按钮

】Shopify-将尺寸变体从选择下拉菜单更改为按钮【英文标题】:Shopify-Changesizevariantfromselectdropdowntobuttons【发布时间】:2020-07-2807:13:45【问题描述】:我想将我的变体显示从下拉(选择)更改为使用按钮。我在网上其他地方找不到... 查看详情

有没有办法在 woocommerce 结账时“浮动标签”? (如 Shopify)

】有没有办法在woocommerce结账时“浮动标签”?(如Shopify)【英文标题】:Isthereawayto\'floatthelabels\'onthewoocommercecheckout?(likeShopify)【发布时间】:2019-06-1823:44:29【问题描述】:我正在尝试在我的WooCommerce结帐页面中复制Shopify结帐的... 查看详情

在 build.gradle 文件中添加 buildFeatures 时出错

...lefile【发布时间】:2020-02-2917:35:44【问题描述】:我正在尝试compose,它是Andoridjetpack中的一个新功能。下面是我的代码。我在app的build.gradle文件中添加buildfeatures,而不是在根文件夹中。androidc 查看详情

尝试在 Spring Boot 中更新时间表时出错

】尝试在SpringBoot中更新时间表时出错【英文标题】:ErrortryingtoupdatetimeTableinspringboot【发布时间】:2020-02-0511:08:55【问题描述】:我是SpringBoot广告的新手,目前正在从事时间表生成支持项目。添加时间表在我的系统中正常工作,... 查看详情

将元素添加到链表后面时出错

...edlist【发布时间】:2013-02-0211:37:44【问题描述】:我正在尝试将一个元素添加到链表的后面。我能够添加元素,并且在第一次尝试时一切正常,但是当我尝试添加另一个元素时,之前添加的元素变成了垃圾值。当我用函数声明中... 查看详情

在 gradle 项目中添加 graphql 依赖项时出错

...\'com.graphql-java:graphql-java:15.0\'但它播种了以下错误。我还尝试更改graphQ 查看详情

Shopify DAWN 主题 - 在购物车页面中添加自定义字段并在订单管理面板中显示结果

】ShopifyDAWN主题-在购物车页面中添加自定义字段并在订单管理面板中显示结果【英文标题】:ShopifyDAWNTheme-AddcustomfieldsinCartpageandShowresultsinOrdersAdminpanel【发布时间】:2022-01-1301:17:45【问题描述】:尝试了另一个开发人员在Shopify主... 查看详情