Du kannst mit dem Snippet die Gesamtproduktzahl des WooCommerce-Warenkorbs so einstellen, dass die Produktanzahl nur durch eine bestimmte Zahl teilbar ist. Wenn die Produktanzahl nicht durch diese Zahl teilbar ist, geht es nicht weiter zur Kasse. Anstatt erscheint eine Fehlermeldung.
// Check cart items conditionally displaying an error notice and avoiding checkout
add_action( 'woocommerce_check_cart_items', 'check_cart_items_conditionally' );
function check_cart_items_conditionally() {
$multiple_of = 6; // <= Here set the "multiple of" number
if ( ( WC()->cart->get_cart_contents_count() % $multiple_of ) != 0 ) {
wc_add_notice( sprintf( __('Die Anzahl der Produkte muss durch %s teilbar sein', 'woocommerce'), $multiple_of ), 'error' );
}
}