Make Only One Item In Cart For Checkout

make only one item in cart for checkout

Make Only One Item In Cart For Checkout

 |   |  1
WooCommerce WordPress

Here, By this you can Make only one item in cart for checkout in your WordPress – WooCommerce. If you add an another item to cart, then previous one will be removed from cart.

Filter / actions I used:-

add_filter( 'woocommerce_add_to_cart_validation', 'woo_custom_add_to_cart_before' );

Callback:-

// before addto cart, only allow 1 item in a cart
function woo_custom_add_to_cart_before( $cart_item_data ) {
  global $woocommerce;
  $woocommerce->cart->empty_cart();

  // Do nothing with the data and return
  return true;
}

Cheersss..


50 Claps

Show your love in the form of Claps and Comments...

Comments...

Arjun K - 

Kidu kidu