2
Woocommerce所做的是什麼...如何跳過「你不能再添加到你的購物車」woocommerce錯誤,並直接跳到結帳?
當產品被單獨出售,並在產品中添加到購物車購物車和用戶點擊已經存在,Woocommerce顯示錯誤消息「不能在另一個添加到您的購物車.. ...查看購物車」
代替上述流程我要的..
當客戶點擊加入購物車,如果產品在購物車中已經存在那麼woocommerce應該重定向到結賬頁面暢通無阻。
我認爲這可以通過在Woocommerce Plugin的class-wc-cart.php中編輯幾行代碼來實現。
的是如下:
// Force quantity to 1 if sold individually and check for existing item in cart
if ($product_data->is_sold_individually()) {
$quantity = apply_filters('woocommerce_add_to_cart_sold_individually_quantity', 1, $quantity, $product_id, $variation_id, $cart_item_data);
$in_cart_quantity = $cart_item_key ? $this->cart_contents[ $cart_item_key ]['quantity'] : 0;
if ($in_cart_quantity > 0) {
throw new Exception(sprintf('<a href="%s" class="button wc-forward">%s</a> %s', wc_get_cart_url(), __('View Cart', 'woocommerce'), sprintf(__('You cannot add another "%s" to your cart.', 'woocommerce'), $product_data->get_title())));
}
}
[Checkout with a single product:verify if any product is in the cart,and give error](http://stackoverflow.com/questions/27030769/checkout-with-a-single-product-verify -if-any-product-is-the-cart-and-give-e) – BenB
我的問題與標記爲可能的重複問題有點不同:http://stackoverflow.com/questions/27030769/checkout -with-A-單品 - 驗證 - 如果 - 任何產品 - 是 - 在最推車和給-E – Manju