장바구니에 제품이 있는지 확인하는 방법을 모르겠다. 체크 아웃을 위해 하나의 제품 만 허용하면됩니다.단일 제품으로 체크 아웃 : 어떤 제품이 장바구니에 들어 있는지 확인하고 오류가 있음
동일한 제품이 이미 장바구니에있는 경우 제품을 추가하지 못하도록하기 위해 wc-cart.php 클래스에 사용되는 코드는 다음과 같습니다. 꽤 유사해야하지만 일부 WP가 누락되었습니다. 어떤 종류의 제품을 정의하기위한 변수. this code도 시도했지만 functions.php에서는 작동하지 않습니다 (아니요, 저는 하위 테마를 사용하지 않습니다).
if ($product_data->is_sold_individually()) {
$in_cart_quantity = $cart_item_key ? $this->cart_contents[ $cart_item_key ]['quantity'] : 0;
// If it's greater than 0, it's already in the cart
if ($in_cart_quantity > 0) {
wc_add_notice(sprintf(
'<a href="%s" class="button wc-forward">%s</a> %s',
$this->get_cart_url(),
__('View Cart', 'woocommerce'),
sprintf(__('You cannot add another "%s" to your cart.', 'woocommerce'), $product_data->get_title())
), 'error');
return false;
}
}
감사합니다.
카트를 1 아이템 * total * 또는 특정 아이템의 단 하나 수량으로 제한 하시겠습니까? (후자의 경우 개별적으로 판매 할 품목을 설정하십시오.) – helgatheviking
상품 1 개 모두 – GCW
[가능한 한 [Woocommerce가 필요함] 카트에 1 개 제품 만 허용 가능합니다. 제품이 이미 장바구니에 있고 다른 1 개가 추가 된 경우 이전 제품이 제거되어야합니다.] (http://stackoverflow.com/questions/21363268/need-woocommerce-to-only-allow-1-product-in- the-cart-if-a-product-in-already-in) – helgatheviking