我正在使用shopify ajax api将产品添加到我的客户购物车中,并且有一个带有以下代码的js文件
Shopify.onError = function(error) {
alert('Error: ' + error.message);
},
Shopify.onCartUpdate = function(cart) {
alert("There are now "+ cart.item_count + " items in the cart.");
},
Shopify.onItemAdded = function(line_item) {
alert(line_item.title + ' Was aloted to your shopping cart');
},
Shopify.onProduct = function(product) {
alert('Received everything we ever wanted to know about '+ product.title);
},
我的印象将取决于ajax结果返回上述消息之一
我正在使用以下声明进行通话
<button class="button" onclick="Shopify.addItem(jQuery('#add_item').val(), jQuery('#add_item_qty').val());return false"><i class="foundicon-cart"></i> Add to cart</button>
虽然返回默认消息
但正在工作答案 0 :(得分:2)
似乎语法问题},
应为};
,例如:
Shopify.onCartUpdate = function(cart) {
alert("There are now "+ cart.item_count + " items in the cart.");
},
应该是
Shopify.onCartUpdate = function(cart) {
alert("There are now "+ cart.item_count + " items in the cart.");
};