ich komme da leider nicht weiter und würde mich über jede hilfe freuen...
in meinem weinshop muss man aus versandgründen immer mindestens 3 weinflaschen bestellen. das klappt auch sehr gut mit dem u. a. code. nun habe ich aber ein produkt zusammengestllt, dass bereits aus 3 flaschen besteht. wenn man nun 3 weine und das Produktpackage bestellt sind das 4 einheiten und somit kann man das ganze im shop nicht bestellen. wie schaffe ich es nun dass das Produktpackage aus der 3er Regel rausgenommen wird?
hier der code
// check that cart items quantities totals are in multiples of 3
add_action( 'woocommerce_check_cart_items', 'woocommerce_check_cart_quantities' );
function woocommerce_check_cart_quantities() {
global $woocommerce;
$multiples = 3;
$total_products = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$total_products += $values['quantity'];
}
if ( ( $total_products % $multiples ) > 0 )
$woocommerce->add_error( sprintf( __('Bitte beachten Sie, dass die Bestellmenge aus Versandgründen durch %s teilbar sein muss.', 'woocommerce'), $multiples ) );
}
// Limit cart items with a certain shipping class to be purchased in multiple only
add_action( 'woocommerce_check_cart_items', 'woocommerce_check_cart_quantities_for_class' );
function woocommerce_check_cart_quantities_for_class() {
global $woocommerce;
$multiples = 3;
$class = 'bottle';
$total_products = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$product = get_product( $values['product_id'] );
if ( $product->get_shipping_class() == $class ) {
$total_products += $values['quantity'];
}
}
if ( ( $total_products % $multiples ) > 0 )
$woocommerce->add_error( sprintf( __('Ihre Bestellmenge muss aus Versandgründen durch %s teilbar sein.', 'woocommerce'), $multiples ) );
}
?>
<?php