context->cart->id_address_invoice); if (!Validate::isLoadedObject($address) && Tools::getValue('id_cart')) { $cart = new Cart((int)Tools::getValue('id_cart')); if (Validate::isLoadedObject($cart)) { $address = new Address((int)$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) { if (!isset($this->context->customer) || !Validate::isLoadedObject($this->context->customer)) { if (isset($cart) && Validate::isLoadedObject($cart)) { $this->context->customer = new Customer((int)$cart->id_customer); } } $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'); $country = Tools::getValue('country'); $reseau = Tools::getValue('reseau'); $so_delivery = new SoFlexibiliteDelivery(); $so_delivery->id_cart = (int)$id_cart; $so_delivery->id_order = -time(); $so_delivery->id_point = pSQL(sprintf('%06s', $id)); $so_delivery->id_customer = (int)$this->context->customer->id; $so_delivery->firstname = $address->firstname; $so_delivery->lastname = $address->lastname; $so_delivery->company = $address->company; $so_delivery->telephone = pSQL($phone); $so_delivery->email = pSQL($this->context->customer->email); $so_delivery->type = $type; $so_delivery->libelle = pSQL($libelle); $so_delivery->indice = pSQL($indice); $so_delivery->postcode = pSQL($codePostal); $so_delivery->city = pSQL($commune); $so_delivery->country = pSQL($country); $so_delivery->address1 = pSQL($adresse1); $so_delivery->address2 = pSQL(''); $so_delivery->lieudit = pSQL(''); $so_delivery->reseau = pSQL($reseau); $status = (bool)$so_delivery->saveDelivery(); SoFlexibiliteCarrierFeeChecker::set($id_cart, $this->context->customer->id, $country); } 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();