restriction with carrier priority
This commit is contained in:
parent
b250ea6d3d
commit
6cc03d0287
@ -55,9 +55,11 @@ class ParentOrderController extends ParentOrderControllerCore {
|
||||
$cart_products = self::$cart->getProducts();
|
||||
if(count($cart_products) > 0) {
|
||||
|
||||
$_carriers = array();
|
||||
$_sales = array();
|
||||
$_carriers = array();
|
||||
$carrier_uniq = array();
|
||||
$count_carriers = array();
|
||||
$dropshipping = false;
|
||||
$shipping_only_athome = false;
|
||||
foreach ($cart_products as $key => $cart_product) {
|
||||
$sale = Sale::getSaleFromCategory($cart_product['id_category_default']);
|
||||
@ -80,11 +82,13 @@ class ParentOrderController extends ParentOrderControllerCore {
|
||||
&& !in_array($carrier['id_carrier'], $carrier_uniq)) {
|
||||
$_carriers[] = $carrier;
|
||||
$carrier_uniq[] = $carrier['id_carrier'];
|
||||
if((int)$carrier['id_carrier'] == 22) {
|
||||
$dropshipping = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// si multiple vente dont vente consommables
|
||||
foreach ($_sales as $key => $carriers) {
|
||||
if ((int) $key == _SHOP_PRIVATESALES_CONSUMABLE) {
|
||||
@ -106,8 +110,16 @@ class ParentOrderController extends ParentOrderControllerCore {
|
||||
} elseif (count($_sales)==1) {
|
||||
// $carrier_shipping_cost = 5;
|
||||
}
|
||||
} else {
|
||||
foreach ($carriers as $key => $value) {
|
||||
if(isset($count_carriers[(int)$value])) {
|
||||
$count_carriers[(int)$value]++;
|
||||
} else {
|
||||
$count_carriers[(int)$value] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// si multiple carriers
|
||||
if (count($_carriers) > 1) {
|
||||
@ -141,11 +153,17 @@ class ParentOrderController extends ParentOrderControllerCore {
|
||||
// Gestion carrier socolissimo (soflexibilite)
|
||||
$carriers_socol = array();
|
||||
foreach ($_carriers as $key => $carrier) {
|
||||
if($dropshipping && $carrier['id_carrier'] == 22) {
|
||||
$carrier_drop = $carrier;
|
||||
}
|
||||
if ($carrier['external_module_name'] == "soflexibilite") {
|
||||
$carriers_socol[] = $carrier;
|
||||
}
|
||||
}
|
||||
if (!empty($carriers_socol)){
|
||||
if(isset($carrier_drop) && !$shipping_only_athome) {
|
||||
unset($carriers);
|
||||
$carriers[0] = $carrier_drop;
|
||||
} elseif (!empty($carriers_socol)){
|
||||
unset($carriers);
|
||||
$carriers = $carriers_socol;
|
||||
} else {
|
||||
@ -164,17 +182,27 @@ class ParentOrderController extends ParentOrderControllerCore {
|
||||
} else {
|
||||
$carriers = $_carriers;
|
||||
}
|
||||
|
||||
// distinction "at home" et "out of home"
|
||||
$carriers_ah = array();
|
||||
$carriers_ooh = array();
|
||||
$config_carrier_ooh = array(88,89); // prod
|
||||
//$config_carrier_ooh = array(88,89); // prod
|
||||
// $config_carrier_ooh = array(47,48); // dev
|
||||
// $config_carrier_ooh = array(40,45); // local
|
||||
$config_carrier_ooh = array(40,45); // local
|
||||
foreach ($carriers as $carrier) {
|
||||
if($shipping_only_athome && $carrier['id_carrier'] != 87) { // prod
|
||||
// if($shipping_only_athome && $carrier['id_carrier'] != 45) { // dev
|
||||
// if($shipping_only_athome && $carrier['id_carrier'] != 38) { // local
|
||||
//if($shipping_only_athome && $carrier['id_carrier'] != 87) { // prod
|
||||
if($shipping_only_athome && $carrier['id_carrier'] != 45) { // dev
|
||||
//if($shipping_only_athome && $carrier['id_carrier'] != 38) { // local
|
||||
continue;
|
||||
}
|
||||
// if($carrier['id_carrier'] != 87
|
||||
// && isset($count_carriers[(int)$carrier['id_carrier']]) && isset($count_carriers[87])
|
||||
// && $count_carriers[(int)$carrier['id_carrier']] < $count_carriers[87]) { // prod
|
||||
if($carrier['id_carrier'] != 45
|
||||
&& isset($count_carriers[(int)$carrier['id_carrier']]) && isset($count_carriers[45])
|
||||
&& $count_carriers[(int)$carrier['id_carrier']] < $count_carriers[45]) { // dev
|
||||
// if($carrier['id_carrier'] != 38
|
||||
// && isset($count_carriers[(int)$carrier['id_carrier']]) && isset($count_carriers[38])
|
||||
// && $count_carriers[(int)$carrier['id_carrier']] < $count_carriers[38]) { //local
|
||||
continue;
|
||||
}
|
||||
if (in_array($carrier['id_carrier'], $config_carrier_ooh) ){
|
||||
@ -183,11 +211,10 @@ class ParentOrderController extends ParentOrderControllerCore {
|
||||
$carriers_ah[] = $carrier;
|
||||
}
|
||||
}
|
||||
|
||||
// fix a check !
|
||||
if (count($carriers_ah) > 0) {
|
||||
unset($carriers);
|
||||
$carriers = $carriers_ah;
|
||||
$carriers = $carriers_ah;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user