habe es nun gemacht, der warenkorb muss aber immer noch durch 3 teilbar sein...
<?php
// 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 $product;
if ( $product->id == 594 ) {
return;
}
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
/********** KLASIK DEFINITION *************/
global $themeoptionsvalue, $meta_boxes;
if ( ! isset( $content_width ) ) $content_width = 1140;
$child_path = get_stylesheet_directory() . '/';
//$admin_path = get_template_directory() . '/admin/';
$includes_path = get_template_directory() . '/includes/';
$meta_boxes = array();
define('KLASIK_THEMENAME', 'Klasik');
define('KLASIK_PARENTMENU_SLUG', 'klasiktheme-settings');
/********** END KLASIK DEFINITION *************/
// Theme Options
require_once $includes_path . 'theme-admin.php';
//Theme init
require_once $includes_path . 'theme-init.php';
//Metabox Function
require_once $includes_path . 'theme-metaboxes.php';
//Widgets
require_once $includes_path . 'theme-widgets.php';
//Sidebar
require_once $includes_path . 'theme-sidebar.php';
//Additional function
require_once $includes_path . 'theme-function.php';
//Header function
require_once $includes_path . 'header-function.php';
//Footer function
require_once $includes_path . 'footer-function.php';
//Loading jQuery
require_once $includes_path . 'theme-scripts.php';
//Loading Style Css
require_once $includes_path . 'theme-styles.php';
if(file_exists($child_path . 'includes/child-functions.php')){
require_once $child_path . 'includes/child-functions.php';
}
if(file_exists($child_path . 'includes/child-metaboxes.php')){
require_once $child_path . 'includes/child-metaboxes.php';
}
if(file_exists($child_path . 'includes/child-shortcodes.php')){
require_once $child_path . 'includes/child-shortcodes.php';
}