我們銷售汽車零部件,每個零件只適合某些年份,製造商,型號,子模型等。由於我們的變體超出Shopify的限制,因此我正在考慮爲每個零件添加一個metefield,以包含所有可能組合的JSON描述可用於該車輛。我想將這些數據解析爲產品頁面上的一系列級聯下拉選擇列表。使用下面的JSON示例,如果您在第一個選擇列表中選擇1973,則可以在第二個選擇列表中選擇Chevrolet或GMC。第三個列表將顯示可用模型,第四個選擇列表將允許用戶選擇公升等。如何從Shopify中的Metafield JSON創建級聯選擇列表?
不幸的是,我不知道如何將這個JSON數據提供給產品液體中的選擇列表,我甚至不確定JSON格式是否正確。任何人都可以幫助我開始使用,或者將我引導至可幫助我學習在Shopify產品液體上顯示此數據的後續步驟的資源。再次請記住,這個JSON將被存儲在一個metafield中。
以下是metafield JSON的一個部分的一個例子:
{"VEHICLES":[{"Year":"1973","Make":"Chevrolet","Model":"K20 Pickup","Submodel":"","Liter":"4.1"},{"Year":"1973","Make":"Chevrolet","Model":"K20 Pickup","Submodel":"","Liter":"4.8"},{"Year":"1973","Make":"Chevrolet","Model":"K20 Pickup","Submodel":"","Liter":"5.0"},{"Year":"1973","Make":"Chevrolet","Model":"K20 Pickup","Submodel":"","Liter":"5.7"},{"Year":"1973","Make":"Chevrolet","Model":"K20 Pickup","Submodel":"","Liter":"7.4"},{"Year":"1973","Make":"Chevrolet","Model":"K30 Pickup","Submodel":"","Liter":"4.1"},{"Year":"1973","Make":"Chevrolet","Model":"K30 Pickup","Submodel":"","Liter":"4.8"},{"Year":"1973","Make":"Chevrolet","Model":"K30 Pickup","Submodel":"","Liter":"5.0"},{"Year":"1973","Make":"Chevrolet","Model":"K30 Pickup","Submodel":"","Liter":"5.7"},{"Year":"1973","Make":"Chevrolet","Model":"K30 Pickup","Submodel":"","Liter":"7.4"},{"Year":"1973","Make":"GMC","Model":"K25/K2500 Pickup","Submodel":"","Liter":"4.1"},{"Year":"1973","Make":"GMC","Model":"K25/K2500 Pickup","Submodel":"","Liter":"4.8"},{"Year":"1973","Make":"GMC","Model":"K25/K2500 Pickup","Submodel":"","Liter":"5.7"},{"Year":"1973","Make":"GMC","Model":"K25/K2500 Pickup","Submodel":"","Liter":"7.4"},{"Year":"1973","Make":"GMC","Model":"K35/K3500 Pickup","Submodel":"","Liter":"4.1"},{"Year":"1973","Make":"GMC","Model":"K35/K3500 Pickup","Submodel":"","Liter":"4.8"},{"Year":"1973","Make":"GMC","Model":"K35/K3500 Pickup","Submodel":"","Liter":"5.0"},{"Year":"1973","Make":"GMC","Model":"K35/K3500 Pickup","Submodel":"","Liter":"5.0"},{"Year":"1973","Make":"GMC","Model":"K35/K3500 Pickup","Submodel":"","Liter":"5.7"},{"Year":"1973","Make":"GMC","Model":"K35/K3500 Pickup","Submodel":"","Liter":"7.4"},]}
你無法做到這種模式。在metafield中存儲JSON是很好的,但只有前端客戶端Javascript才能解析JSON並進行處理。因此,假設您使用JSON Payload對產品進行編碼,通知您前端是什麼產品,那麼祝您好運,編寫前端代碼,然後使Shopify產品體驗更好。 由此我的意思是你現在將能夠做什麼?不知何故確保客戶只顯示正確的產品?或者來自JSON數據的過濾器可能確保客戶獲得正確的變體? –
謝謝大衛。這就說得通了。是的,其中的一部分只是爲了確保客戶選擇可用的變體並且不訂購不適合他們車輛的產品。我也希望,正如你所指出的那樣,我們可以用它來爲主頁和分類頁面創建一個配件選擇器。問題是我們的大多數產品與我列出的產品相似(很多變體,但SKU沒有變化),但是我們的一些產品是真正的變體(即,如果您更改顏色或尺寸,它會更改SKU) 。簡而言之,我很難提出一個有效的數據模型。 – bonaventure
我有點grok。前一段時間,我的任務是製作一家商店銷售輪胎。品牌,型號年份數據導致選擇輪胎。一個巨大的,並沒有完全準備好黃金時段的電子商務領域... –