2016-07-25 138 views
1

我在woocommerce面臨這個問題。當我們從購物車中取出產品時,請更新購物車按鈕禁用。刷新頁面工作正常後。產品從購物車中刪除後刷新頁面Woocommerce

我想這個鉤子:

woocommerce_cart_item_removed 

但它不工作任何回報。

+0

請提供一個例子。因此,我可以幫助你。 – WisdmLabs

+2

嗨WisdmLabs,當購物車頁面包含多於一個產品,並且當用戶從購物車中移除一個產品時,則用戶想要增加另一個產品數量。但用戶無法更新購物車。因爲更新購物車按鈕被禁用。這是主要問題。 – webtuts4u

回答

1

在Woocommerce的最新版本爲如this commit描述提供一個JavaScript回調觸發:

/** 
* Update the .cart_totals div with a string of html. 
* 
* @param {String} html_str The HTML string with which to replace the div. 
*/ 
var update_cart_totals_div = function(html_str) { 
    $('.cart_totals').replaceWith(html_str); 
    $(document.body).trigger('updated_cart_totals'); 
}; 

所以,你可以添加一段JavaScript時,該觸發器被觸發運行,並啓用按鈕或乾脆刷新頁面。例如:

$('body').on('updated_cart_totals',function() { 
    $('.shop_table.cart').closest('form').find('input[name="update_cart"]').prop('disabled', false); // this will enable the button. 
    //location.reload(); // uncomment this line to refresh the page. 
}); 
+0

感謝leendertvb爲您的答案。試試這在我的下一個網站:) – webtuts4u

相關問題