【发布时间】:2021-09-01 21:52:53
【问题描述】:
我无法通过 Shopify API 更新购物车。我正在使用的代码如下:
<!-- Quantity Box on Cart Page -->
<script>
$('.qty_wrap .qty_button').on('click', function(){
var qty = $(this).parent('.qty_wrap').find('.qty_input').val();
var currentVariant = $(this).parent('.qty_wrap').find('.qty_input').attr("data-variant");
var subTotal = $(this).parents('.card').find('#subtotal').text();
var loopKey = $(this).parents('.card').attr("data-key");
if($(this).hasClass('qty_plus')) {
qty++;
}else {
if(qty > 1) {
qty--;
}
}
$(this).parent('.qty_wrap').find('.qty_input').val(qty);
console.log(loopKey);
console.log(qty);
$.post('/cart/change.js', { id: loopKey, quantity: qty });
});
</script>
我使用线路键作为 ID,我也尝试过变体 ID,尽管文档没有建议这样做。任何帮助都会很棒,不会通过控制台返回任何错误。
【问题讨论】:
-
需要现场检查,代码对这个问题一无所知
标签: shopify