Привет, у меня есть визуальные образы, Кнопка первого щелчка по кнопке «Отправить другу», проверьте валидацию размера qty для каждой категории, выведите сообщение об ошибке поверх виджета корзины , Как подсчитать товар в каждой категии в корзине с помощью woocommerce? Заранее спасибоКак ограничить товар в корзине для каждой категории в woocommerce
public function check_product_in_cart($product_in_cart) {
//Check to see if user has product in cart
global $woocommerce;
// start of the loop that fetches the cart items
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
$_product = $values['data'];
$terms = get_the_terms($_product->id, 'product_cat');
// second level loop search, in case some items have several categories
// this is where I started editing Guillaume's code
$cat_ids = array();
foreach ($terms as $term) {
$cat_ids[] = $term->term_id;
}
if(in_array(70, (array)$cat_ids) ||in_array(69, (array)$cat_ids) || in_array(68, (array)$cat_ids)) {
//if exist in "strain" category
//output true
$product_in_cart = true;
//how to count all item in this category??? Thanks
}
}
return $product_in_cart;
}