0
我在Datalayer中工作,我試圖做一個替換值。例如,如果item.listPrice等於0.01,這將打印0.00,但不能正常工作。如何做到替換成json發生器代碼
function get_products() {
try {
vtexjs.checkout.getOrderForm().done(function(a) {
console.log("Push order", a);
arr_products_cart = [];
$(a.items).each(function(a, b) {
arr_products_cart.push({
name: b.name,
id: b.id,
price: regex_price(b.listPrice),
brand: brand,
category: b.productCategories[Object.keys(b.productCategories)[1]],
variant: b.skuName
});
if ("0,01" === b.listPrice || "0.01" === b.listPrice) arr_products_cart.push({
price: "0.00"
});
arr_products_cart_category.push({
id: b.id,
category: b.productCategories[Object.keys(b.productCategories)[1]],
variant: b.skuName
});
});
set_products_cart();
cart_qty_register_category();
});
} catch (a) {
console.warn("get_products error", a);
}
}
使用該溶液是顯示一個消息 「未捕獲的SyntaxError:意外令牌如果」 –