Specific with BPR (Point Relais mais Bureau De poste)

This commit is contained in:
Michael RICOIS 2017-10-26 17:14:02 +02:00
parent c0f9476da6
commit e3c5b8a528

View File

@ -1280,7 +1280,10 @@ class soflexibilite extends CarrierModule
} }
if (in_array($params['order']->id_carrier, $this->id_carrier_so)) { if (in_array($params['order']->id_carrier, $this->id_carrier_so)) {
if (!in_array($params['order']->id_carrier, array($this->id_carrier_so['SOFLEXIBILITE_DOM_ID'], $this->id_carrier_so['SOFLEXIBILITE_DOS_ID']))) { if (!in_array($params['order']->id_carrier, array(
$this->id_carrier_so['SOFLEXIBILITE_DOM_ID'],
$this->id_carrier_so['SOFLEXIBILITE_DOS_ID']))) {
$soDelivery = new SoFlexibiliteDelivery((int)$params['cart']->id, (int)$params['cart']->id_customer); $soDelivery = new SoFlexibiliteDelivery((int)$params['cart']->id, (int)$params['cart']->id_customer);
$soDelivery->loadDelivery(); $soDelivery->loadDelivery();
@ -1328,17 +1331,24 @@ class soflexibilite extends CarrierModule
$address_delivery = new Address($id_address_new); $address_delivery = new Address($id_address_new);
if (Validate::isLoadedObject($address_delivery)) { if (Validate::isLoadedObject($address_delivery)) {
// Change lastname according to the address
$soDelivery->lastname = $address->lastname; $soDelivery->lastname = $address->lastname;
// If type = BPR, change firstname according to the address
if ($soDelivery->type == 'BPR') {
$soDelivery->firstname = $address_delivery->firstname;
}
} }
$soDelivery->saveDelivery();
if (Validate::isLoadedObject($address)) { if (Validate::isLoadedObject($address)) {
if (is_null($soDelivery->telephone) || empty($soDelivery->telephone) || Tools::strlen($soDelivery->telephone) < 7) { if (is_null($soDelivery->telephone) || empty($soDelivery->telephone) || Tools::strlen($soDelivery->telephone) < 7) {
$soDelivery->telephone = $address->phone_mobile ? $address->phone_mobile : ($address->phone ? $address->phone : ''); $soDelivery->telephone = $address->phone_mobile ? $address->phone_mobile : ($address->phone ? $address->phone : '');
} }
} }
$soDelivery->saveDelivery(); $soDelivery->saveDelivery();
} else { }
else {
$soDelivery = new SoFlexibiliteDelivery((int)$params['cart']->id, (int)$params['cart']->id_customer); $soDelivery = new SoFlexibiliteDelivery((int)$params['cart']->id, (int)$params['cart']->id_customer);
$soDelivery->loadDelivery(); $soDelivery->loadDelivery();
@ -1392,7 +1402,8 @@ class soflexibilite extends CarrierModule
$soDelivery->saveDelivery(); $soDelivery->saveDelivery();
} }
} else { }
else {
$soDelivery = new SoFlexibiliteDelivery(); $soDelivery = new SoFlexibiliteDelivery();
$soDelivery->removeDelivery((int)$params['cart']->id); $soDelivery->removeDelivery((int)$params['cart']->id);
} }