context->cart->id_address_invoice); if (!Validate::isLoadedObject($address)) { if ($debug) { die(sprintf( '%s(#%d): Validate::isLoadedObject(%d) failed'."\n", basename(__FILE__), __LINE__, (int)$this->context->cart->id_address_delivery )); } $pass = false; } if (!(Tools::getValue('id') && Tools::getValue('type') && Tools::getValue('id_cart') && Tools::getValue('libelle') && Tools::getValue('adresse1') && Tools::getValue('code_postal') && Tools::getValue('commune'))) { if ($debug) { die(sprintf( '%s(#%d): Missing Parameter'."\n", basename(__FILE__), __LINE__, (int)$this->context->cart->id_address_delivery )); } $pass = false; } if ($pass) { $id = (int)Tools::getValue('id'); $type = Tools::getValue('type'); $id_cart = (int)Tools::getValue('id_cart'); $phone = Tools::getValue('phone'); $libelle = Tools::getValue('libelle'); $indice = Tools::getValue('indice'); $codePostal = Tools::getValue('code_postal'); $commune = Tools::getValue('commune'); $adresse1 = Tools::getValue('adresse1'); // TODO sent country $soDelivery = new SoFlexibiliteDelivery(); $soDelivery->id_cart = (int)$id_cart; $soDelivery->id_order = -time(); $soDelivery->id_point = pSQL(sprintf('%06s', $id)); $soDelivery->id_customer = (int)$this->context->customer->id; $soDelivery->firstname = $address->firstname; $soDelivery->lastname = $address->lastname; $soDelivery->company = $address->company; $soDelivery->telephone = pSQL($phone); $soDelivery->email = pSQL($this->context->customer->email); $soDelivery->type = $type; $soDelivery->libelle = pSQL($libelle); $soDelivery->indice = pSQL($indice); $soDelivery->postcode = pSQL($codePostal); $soDelivery->city = pSQL($commune); $soDelivery->country = (($type == 'CMT' || $type == 'BDP') ? pSQL('BE') : pSQL('FR')); $soDelivery->address1 = pSQL($adresse1); $soDelivery->address2 = pSQL(''); $soDelivery->lieudit = pSQL(''); $status = $soDelivery->saveDelivery() ? true : false; } else { $status = false; } $result = ob_get_clean(); if ($result) { $output = $result; } else { $output = null; } $json = array( 'output' => $output, 'status' => $status ); die(Tools::jsonEncode($json)); } } $so_flexibilite_delivery_save = new SoFlexibiliteDeliverySave(); $so_flexibilite_delivery_save->save();