1 回答

TA貢獻2021條經(jīng)驗 獲得超8個贊
這是一個循環(huán),它根據(jù)您提供的代碼遍歷 line_items 對象的 meta_data。
var lineitems="";
var decoration = "";
for (var i in myData.line_items)
{
var product_name = myData.line_items[i].name;
var itemName = myData.line_items[i].name;
var quantity = myData.line_items[i].quantity;
var metaData = myData.line_items[i].meta_data;
for (var j in metaData)
{
for (var key in metaData[j])
{
var decorationitems = "Item: " + key + " Optie: " + metaData[j][key] + '\n';
decoration = decoration + decorationitems;
}
}
var product_items = quantity + " x " + itemName + '\n' + decoration + '\n';
lineitems = lineitems + product_items;
}
添加回答
舉報