getProducts() as $product) { if(($sale = Sale::getSaleFromCategory($product['id_category_default'])) !== NULL) { if($sale->isFinished() || !$sale->enabled) { self::$cart->deleteProduct($product['id_product'], $product['id_product_attribute'], $product['id_customization']); $removed = TRUE; } } } if($removed === TRUE) { self::$smarty->assign(array( 'products_removed' => TRUE, )); $this->nbProducts = self::$cart->nbProducts(); } if(!$this->nbProducts) { $this->step = -1; } } parent::preProcess(); } protected function _assignCarrier() { $customer = new Customer((int)(self::$cookie->id_customer)); $address = new Address((int)(self::$cart->id_address_delivery)); $id_zone = Address::getZoneById((int)($address->id)); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups()); $carriers_special = Cart::$carrier_special; $only_gifts = TRUE; foreach(self::$cart->getProducts() as $p) { if($p['id_product'] != 4840) { $only_gifts = FALSE; break; } } self::$smarty->assign('only_gifts', $only_gifts); $sale_delivery = array(); // Restriction du choix du transporteur if(Module::isInstalled('privatesales')) { if(Configuration::get('PRIVATESALES_CARRIERFENCE') ) { $cart_products = self::$cart->getProducts(); if(count($cart_products) > 0) { $_carriers = array(); $carrier_uniq = array(); foreach ($cart_products as $key => $cart_product) { $sale = Sale::getSaleFromCategory($cart_product['id_category_default']); if($sale) { $sale_carriers = $sale->getCarriers(); $sale_delivery[] = $sale->delivery_delay; if(count($sale_carriers) == 0) { mail('thibault@antadis.com', '[BBB] Vente sans transporteur', 'La vente ' . $sale->id . ' n\'a aucun transporteur défini pour le panier ' . $cart->id); mail('valentin@bebeboutik.com', '[BBB] Vente sans transporteur', 'La vente ' . $sale->id . ' n\'a aucun transporteur défini pour le panier ' . $cart->id); break; } foreach($carriers as $carrier) { if(in_array($carrier['id_carrier'], $sale_carriers) && !in_array($carrier['id_carrier'], $carrier_uniq)) { $_carriers[] = $carrier; $carrier_uniq[] = $carrier['id_carrier']; } } } } // si multiple carriers if (count($_carriers) > 1) { $extra_carrier = 0; $carrier_extra_available = array(); $id_carrier_available = array(); $id_carrier_available = array_map(function($carrier){ return $carrier['id_carrier']; }, $_carriers); $id_carrier_available = array_unique($id_carrier_available); foreach ($carriers_special as $carrier_special) { if (in_array($carrier_special, $id_carrier_available)) { $extra_carrier++; $carrier_extra_available[] = $carrier_special; } } if ($extra_carrier == 1) { $carrier_final = array(); foreach ($_carriers as $key => $carrier) { if ($carrier['id_carrier'] == $carrier_extra_available[0] ) { $carrier_final = $carrier; break; } } unset($carriers); $carriers[0] = $carrier_final; } else { // TODOOO multi special carrier $carrier_extra_available[] $carrier_final = array(); foreach ($_carriers as $key => $carrier) { if ($carrier['id_carrier'] == $carrier_extra_available[0] ) { $carrier_final = $carrier; break; } } unset($carriers); $carriers[0] = $carrier_final; } } else { $carriers = $_carriers; } } } } self::$smarty->assign(array( 'checked' => $this->_setDefaultCarrierSelection($carriers), 'carriers' => $carriers, 'sale_delivery' => array_unique($sale_delivery), 'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')) )); self::$smarty->assign(array( 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)) )); } protected function _processCarrier() { if(Module::isInstalled('privatesales')) { // if(Configuration::get('PRIVATESALES_CARRIERFENCE')) { // $cart_products = self::$cart->getProducts(); // if(count($cart_products) > 0) { // $sale = Sale::getSaleFromCategory($cart_products[0]['id_category_default']); // if($sale) { // $sale_carriers = $sale->getCarriers(); // if(!in_array(Tools::getValue('id_carrier'), $sale_carriers)) { // $this->errors[] = Tools::displayError('Invalid carrier or no carrier selected'); // } // } // } // } if(count($this->errors) === 0) { parent::_processCarrier(); } } else { parent::_processCarrier(); } } public function setMedia() { parent::setMedia(); global $css_files; $css_files = array_slice($css_files, 0, 1); } }