getProducts() as $product) { $sale = \Sale::getSaleFromCategory((int)$product['id_category_default'], false); $current_sale = array( 'id_sale'=> (int) $sale->id, 'delivery_delay'=> (int) $sale->delivery_delay, 'shipping' => \Sale::getShippingSale((int)$sale->id) ); // Only one delivery id per cart, so we can break now break; } $current_product = $productToAdd; $sale2 = \Sale::getSaleFromCategory($current_product->id_category_default, false); $adding_sale = array( 'id_sale'=> (int) $sale2->id, 'delivery_delay'=> (int) $sale2->delivery_delay, 'shipping' => \Sale::getShippingSale((int)$sale2->id) ); if (!empty($current_sale)) { if ((int)$current_sale['delivery_delay'] == 1 && !\Sale::isCombinable($current_sale,$adding_sale)){ $current_delay = \SaleDelay::getDelayFrontSmallName($current_sale['delivery_delay'], $cookie->id_lang); return sprintf(ApiTools::displayError('Sorry your cart already contains products from a sale shipped within %s. To continue, please confirm your order or empty your cart.', false), $current_delay); } elseif (!\Sale::isCombinable($current_sale,$adding_sale)){ $add_delay = \SaleDelay::getDelayFrontSmallName($adding_sale['delivery_delay'], $cookie->id_lang); return sprintf(ApiTools::displayError('Sorry your cart already contains products from a sale shipped within a special period. We cannot add products from sales shipped within %s. To continue, please confirm your order or empty your cart.', false),$add_delay); } } } return true; } }