Um limite de item no carrinho em wooCommerce

add_filter( 'woocommerce_add_to_cart_validation', 'only_one_item_in_cart', 9999, 2 );
   
function only_one_item_in_cart( $passed, $added_product_id ) {
   wc_empty_cart();
   return $passed;
}
Hamza Najam