public function uninstall()
 {
     if (!parent::uninstall() or !$this->unregisterHook('actionCarrierUpdate') or !Db::getInstance()->Execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'fraktguide_product_names`')) {
         return false;
     } else {
         $carrier_ids_str = Configuration::get('FRAKTGUIDE_CREATED_CARRIER_IDS');
         $carrier_ids = $carrier_ids_str ? explode(';', Configuration::get('FRAKTGUIDE_CREATED_CARRIER_IDS')) : array();
         foreach ($carrier_ids as $carrier_id) {
             $carrier = new Carrier((int) $carrier_id);
             $carrier->deleted = 1;
             if (!$carrier->update()) {
                 return false;
             }
         }
         Configuration::deleteByName('FRAKTGUIDE_CREATED_CARRIER_IDS');
         Configuration::deleteByName('FRAKTGUIDE_CARRIER_IDS');
         Configuration::deleteByName('FRAKTGUIDE_PRODUCTS');
         Configuration::deleteByName('FRAKTGUIDE_EDI');
         Configuration::deleteByName('FRAKTGUIDE_DEBUG_MODE');
         Configuration::deleteByName('FRAKTGUIDE_A_POST_MAX_PRIS');
         Configuration::deleteByName('FRAKTGUIDE_FRA_POSTNUMMER');
         Configuration::deleteByName('FRAKTGUIDE_FORSIKRING');
         Configuration::deleteByName('FRAKTGUIDE_ID_TAX_RULES_GROUP');
         return true;
     }
 }
 private function uninstallCarrier($carrierId)
 {
     //$carrierId = $this->carrierId();
     if (!is_null($carrierId)) {
         $carrier = new Carrier($carrierId);
         $langDefault = (int) Configuration::get('PS_LANG_DEFAULT');
         $carriers = Carrier::getCarriers($langDefault, true, false, false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
         // Если наш перевозчик был по умолчанию, назначим кого-нибудь другого
         if (Configuration::get('PS_CARRIER_DEFAULT') == $carrierId) {
             foreach ($carriers as $c) {
                 if ($c['active'] && !$c['deleted'] && $c['name'] != $carrier->name) {
                     Configuration::updateValue('PS_CARRIER_DEFAULT', $c['id_carrier']);
                 }
             }
         }
         if (!$carrier->deleted) {
             $carrier->deleted = 1;
             if (!$carrier->update()) {
                 return false;
             }
         }
     }
     return true;
 }
 public function deleteShowShipping()
 {
     foreach ($this->carriers as $value) {
         $carriers = new Carrier((int) Configuration::get(self::PREFIX . $value));
         if ($carriers->deleted == '0') {
             $carriers->deleted = 1;
             $carriers->update();
             $previousPage = $_SERVER["HTTP_REFERER"];
             Tools::redirect($previousPage);
         }
     }
 }
 public function uninstall()
 {
     global $cookie;
     $so_id = (int) Configuration::get('SOCOLISSIMO_CARRIER_ID');
     if (!parent::uninstall() or !Db::getInstance()->Execute('DROP TABLE IF EXISTS`' . _DB_PREFIX_ . 'socolissimo_delivery_info`') or !$this->unregisterHook('extraCarrier') or !$this->unregisterHook('payment') or !$this->unregisterHook('AdminOrder') or !$this->unregisterHook('newOrder') or !$this->unregisterHook('updateCarrier') or !Configuration::deleteByName('SOCOLISSIMO_ID') or !Configuration::deleteByName('SOCOLISSIMO_KEY') or !Configuration::deleteByName('SOCOLISSIMO_URL') or !Configuration::deleteByName('SOCOLISSIMO_OVERCOST') or !Configuration::deleteByName('SOCOLISSIMO_PREPARATION_TIME') or !Configuration::deleteByName('SOCOLISSIMO_CARRIER_ID') or !Configuration::deleteByName('SOCOLISSIMO_SUP') or !Configuration::deleteByName('SOCOLISSIMO_SUP_URL') or !Configuration::deleteByName('SOCOLISSIMO_OVERCOST_TAX')) {
         return false;
     }
     //Delete So Carrier
     $soCarrier = new Carrier($so_id);
     //if socolissimo carrier is default set other one as default
     if (Configuration::get('PS_CARRIER_DEFAULT') == (int) $soCarrier->id) {
         $carriersD = Carrier::getCarriers((int) $cookie->id_lang);
         foreach ($carriersD as $carrierD) {
             if ($carrierD['active'] and !$carrierD['deleted'] and $carrierD['name'] != $this->_config['name']) {
                 Configuration::updateValue('PS_CARRIER_DEFAULT', $carrierD['id_carrier']);
             }
         }
     }
     //save old carrier id
     Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_HIST', Configuration::get('SOCOLISSIMO_CARRIER_ID_HIST') . '|' . (int) $soCarrier->id);
     $soCarrier->deleted = 1;
     if (!$soCarrier->update()) {
         return false;
     }
     return true;
 }
 public function ajaxProcessFinishStep()
 {
     $return = array('has_error' => false);
     if (!$this->access('edit')) {
         $return = array('has_error' => true, $return['errors'][] = $this->trans('You do not have permission to use this wizard.', array(), 'Admin.Shipping.Notification'));
     } else {
         $this->validateForm(false);
         if ($id_carrier = Tools::getValue('id_carrier')) {
             $current_carrier = new Carrier((int) $id_carrier);
             // if update we duplicate current Carrier
             /** @var Carrier $new_carrier */
             $new_carrier = $current_carrier->duplicateObject();
             if (Validate::isLoadedObject($new_carrier)) {
                 // Set flag deteled to true for historization
                 $current_carrier->deleted = true;
                 $current_carrier->update();
                 // Fill the new carrier object
                 $this->copyFromPost($new_carrier, $this->table);
                 $new_carrier->position = $current_carrier->position;
                 $new_carrier->update();
                 $this->updateAssoShop((int) $new_carrier->id);
                 $this->duplicateLogo((int) $new_carrier->id, (int) $current_carrier->id);
                 $this->changeGroups((int) $new_carrier->id);
                 //Copy default carrier
                 if (Configuration::get('PS_CARRIER_DEFAULT') == $current_carrier->id) {
                     Configuration::updateValue('PS_CARRIER_DEFAULT', (int) $new_carrier->id);
                 }
                 // Call of hooks
                 Hook::exec('actionCarrierUpdate', array('id_carrier' => (int) $current_carrier->id, 'carrier' => $new_carrier));
                 $this->postImage($new_carrier->id);
                 $this->changeZones($new_carrier->id);
                 $new_carrier->setTaxRulesGroup((int) Tools::getValue('id_tax_rules_group'));
                 $carrier = $new_carrier;
             }
         } else {
             $carrier = new Carrier();
             $this->copyFromPost($carrier, $this->table);
             if (!$carrier->add()) {
                 $return['has_error'] = true;
                 $return['errors'][] = $this->trans('An error occurred while saving this carrier.', array(), 'Admin.Shipping.Notification');
             }
         }
         if ($carrier->is_free) {
             //if carrier is free delete shipping cost
             $carrier->deleteDeliveryPrice('range_weight');
             $carrier->deleteDeliveryPrice('range_price');
         }
         if (Validate::isLoadedObject($carrier)) {
             if (!$this->changeGroups((int) $carrier->id)) {
                 $return['has_error'] = true;
                 $return['errors'][] = $this->trans('An error occurred while saving carrier groups.', array(), 'Admin.Shipping.Notification');
             }
             if (!$this->changeZones((int) $carrier->id)) {
                 $return['has_error'] = true;
                 $return['errors'][] = $this->trans('An error occurred while saving carrier zones.', array(), 'Admin.Shipping.Notification');
             }
             if (!$carrier->is_free) {
                 if (!$this->processRanges((int) $carrier->id)) {
                     $return['has_error'] = true;
                     $return['errors'][] = $this->trans('An error occurred while saving carrier ranges.', array(), 'Admin.Shipping.Notification');
                 }
             }
             if (Shop::isFeatureActive() && !$this->updateAssoShop((int) $carrier->id)) {
                 $return['has_error'] = true;
                 $return['errors'][] = $this->trans('An error occurred while saving associations of shops.', array(), 'Admin.Shipping.Notification');
             }
             if (!$carrier->setTaxRulesGroup((int) Tools::getValue('id_tax_rules_group'))) {
                 $return['has_error'] = true;
                 $return['errors'][] = $this->trans('An error occurred while saving the tax rules group.', array(), 'Admin.Shipping.Notification');
             }
             if (Tools::getValue('logo')) {
                 if (Tools::getValue('logo') == 'null' && file_exists(_PS_SHIP_IMG_DIR_ . $carrier->id . '.jpg')) {
                     unlink(_PS_SHIP_IMG_DIR_ . $carrier->id . '.jpg');
                 } else {
                     $logo = basename(Tools::getValue('logo'));
                     if (!file_exists(_PS_TMP_IMG_DIR_ . $logo) || !copy(_PS_TMP_IMG_DIR_ . $logo, _PS_SHIP_IMG_DIR_ . $carrier->id . '.jpg')) {
                         $return['has_error'] = true;
                         $return['errors'][] = $this->trans('An error occurred while saving carrier logo.', array(), 'Admin.Shipping.Notification');
                     }
                 }
             }
             $return['id_carrier'] = $carrier->id;
         }
     }
     die(json_encode($return));
 }
 public function uninstall()
 {
     // Uninstall
     if (!parent::uninstall() || !Configuration::deleteByName('COURIERSERVICE_OVERCOST') || !Configuration::deleteByName('DELIVERYPOINTS_OVERCOST') || !$this->unregisterHook('updateCarrier') || !$this->unregisterHook('displayBackOfficeHeader') || !DpdCarrierOptions::uninstallDb() || !DpdDeliveryPoints::uninstallDb() || !DpdOrderOptions::uninstallDb() || !DpdDeliveryPrice::uninstallDb()) {
         //          || !$this->removeBulkActionButtons() //Using this only if Overwrite using already other model!
         return false;
     }
     // Delete External Carrier
     $carrier1 = new Carrier((int) Configuration::get('COURIERSERVICE_CARRIER_ID'));
     $carrier2 = new Carrier((int) Configuration::get('DELIVERYPOINTS_CARRIER_ID'));
     // If external carrier is default set other one as default
     if (Configuration::get('PS_CARRIER_DEFAULT') == (int) $carrier1->id || Configuration::get('PS_CARRIER_DEFAULT') == (int) $carrier2->id) {
         $carriers_d = Carrier::getCarriers(Context::getContext()->cookie->id_lang, true, false, false, null, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
         foreach ($carriers_d as $carrier_d) {
             if ($carrier_d['active'] && !$carrier_d['deleted'] && $carrier_d['name'] != $this->_config['name']) {
                 Configuration::updateValue('PS_CARRIER_DEFAULT', $carrier_d['id_carrier']);
             }
         }
     }
     // Then delete Carrier
     $carrier1->deleted = 1;
     $carrier2->deleted = 1;
     if (!$carrier1->update() || !$carrier2->update()) {
         return false;
     }
     $settings = array(self::CONST_PREFIX . 'ENABLED', self::CONST_PREFIX . 'SERVICE_USERNAME', self::CONST_PREFIX . 'SERVICE_USERPASS', self::CONST_PREFIX . 'SERVICE_USERID', self::CONST_PREFIX . 'API_URL', self::CONST_PREFIX . 'BTNSUBMIT', self::CONST_PREFIX . 'TAB', self::CONST_PREFIX . 'USERNAME');
     foreach ($settings as $setting) {
         Configuration::deleteByName($setting);
     }
     $tab = new Tab(Tab::getIdFromClassName('AdminCallcarrier'));
     $tab->delete();
     return true;
 }
 public function uninstall()
 {
     $so_id = (int) Configuration::get('SOCOLISSIMO_CARRIER_ID');
     $so_id_seller = (int) Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER');
     Configuration::deleteByName('SOCOLISSIMO_ID');
     Configuration::deleteByName('SOCOLISSIMO_VERSION');
     Configuration::deleteByName('SOCOLISSIMO_USE_FANCYBOX');
     Configuration::deleteByName('SOCOLISSIMO_USE_IFRAME');
     Configuration::deleteByName('SOCOLISSIMO_KEY');
     Configuration::deleteByName('SOCOLISSIMO_URL');
     Configuration::deleteByName('SOCOLISSIMO_URL_MOBILE');
     Configuration::deleteByName('SOCOLISSIMO_OVERCOST');
     Configuration::deleteByName('SOCOLISSIMO_COST_SELLER');
     Configuration::deleteByName('SOCOLISSIMO_UPG_COUNTRY');
     Configuration::deleteByName('SOCOLISSIMO_PREPARATION_TIME');
     Configuration::deleteByName('SOCOLISSIMO_CARRIER_ID');
     Configuration::deleteByName('SOCOLISSIMO_CARRIER_ID_SELLER');
     Configuration::deleteByName('SOCOLISSIMO_SUP');
     Configuration::deleteByName('SOCOLISSIMO_EXP_BEL');
     Configuration::deleteByName('SOCOLISSIMO_SUP_BELG');
     Configuration::deleteByName('SOCOLISSIMO_SUP_URL');
     Configuration::deleteByName('SOCOLISSIMO_OVERCOST_TAX');
     if (!parent::uninstall() || !Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'socolissimo_delivery_info`') || !$this->unregisterHook('extraCarrier') || !$this->unregisterHook('payment') || !$this->unregisterHook('AdminOrder') || !$this->unregisterHook('newOrder') || !$this->unregisterHook('updateCarrier') || !$this->unregisterHook('paymentTop') || !$this->unregisterHook('backOfficeHeader')) {
         return false;
     }
     // Delete So Carrier
     $so_carrier = new Carrier($so_id);
     // If socolissimo carrier is default set other one as default
     if (Configuration::get('PS_CARRIER_DEFAULT') == (int) $so_carrier->id) {
         $carriers_d = Carrier::getCarriers($this->context->language->id);
         foreach ($carriers_d as $carrier_d) {
             if ($carrier_d['active'] && !$carrier_d['deleted'] && $carrier_d['name'] != $this->config['name']) {
                 Configuration::updateValue('PS_CARRIER_DEFAULT', $carrier_d['id_carrier']);
             }
         }
     }
     // Save old carrier id
     Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_HIST', Configuration::get('SOCOLISSIMO_CARRIER_ID_HIST') . '|' . (int) $so_carrier->id);
     $so_carrier->deleted = 1;
     if (!$so_carrier->update()) {
         return false;
     }
     // Delete So Carrier Seller
     $so_carrier = new Carrier($so_id_seller);
     // If socolissimo carrier is default set other one as default
     if (Configuration::get('PS_CARRIER_DEFAULT') == (int) $so_carrier->id) {
         $carriers_d = Carrier::getCarriers($this->context->language->id);
         foreach ($carriers_d as $carrier_d) {
             if ($carrier_d['active'] && !$carrier_d['deleted'] && $carrier_d['name'] != $this->config['name']) {
                 Configuration::updateValue('PS_CARRIER_DEFAULT', $carrier_d['id_carrier']);
             }
         }
     }
     // Save old carrier id
     Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_HIST', Configuration::get('SOCOLISSIMO_CARRIER_ID_HIST') . '|' . (int) $so_carrier->id);
     $so_carrier->deleted = 1;
     if (!$so_carrier->update()) {
         return false;
     }
     return true;
 }
 /**
  * @param ShopgateOrder $order
  *
  * @return array
  * @throws PrestaShopException
  * @throws ShopgateLibraryException
  */
 public function addOrder(ShopgateOrder $order)
 {
     /**
      * check exits shopgate order
      */
     if (ShopgateOrderPrestashop::loadByOrderNumber($order->getOrderNumber())->status == 1) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_DUPLICATE_ORDER, sprintf('external_order_id: %s', $order->getOrderNumber()), true);
     }
     /** @var CarrierCore $sgCarrier */
     $sgCarrier = new Carrier(Configuration::get('SG_CARRIER_ID'));
     if (version_compare(_PS_VERSION_, '1.5.0', '<') && empty($sgCarrier->name)) {
         $sgCarrier->name = 'shopgate_tmp_carrier';
     }
     if ($order->getShippingType() != ShopgateShipping::DEFAULT_PLUGIN_API_KEY) {
         if ($order->getShippingInfos()->getAmount() > 0) {
             if (version_compare(_PS_VERSION_, '1.5.0', '<')) {
                 ShopgateModObjectModel::updateShippingPrice(pSQL($order->getShippingInfos()->getAmount()));
             } else {
                 $data = array('price' => pSQL($order->getShippingInfos()->getAmount()));
                 $where = 'a.id_carrier = ' . (int) Configuration::get('SG_CARRIER_ID');
                 ObjectModel::updateMultishopTable('Delivery', $data, $where);
             }
             $sgCarrier->is_free = 0;
         } else {
             $sgCarrier->is_free = 1;
         }
     }
     $sgCarrier->update();
     $customerModel = new ShopgateItemsCustomerImportJson($this->getPlugin());
     $paymentModel = new ShopgatePayment($this->getModule());
     $shippingModel = new ShopgateShipping($this->getModule());
     /**
      * read / check customer
      */
     if (!($customerId = Customer::customerExists($order->getMail(), true, false))) {
         /**
          * prepare customer
          */
         $shopgateCustomerItem = new ShopgateCustomer();
         $shopgateCustomerItem->setLastName($order->getInvoiceAddress()->getLastName());
         $shopgateCustomerItem->setFirstName($order->getInvoiceAddress()->getFirstName());
         $shopgateCustomerItem->setGender($order->getInvoiceAddress()->getGender());
         $shopgateCustomerItem->setBirthday($order->getInvoiceAddress()->getBirthday());
         $shopgateCustomerItem->setNewsletterSubscription(Configuration::get('SG_SUBSCRIBE_NEWSLETTER') ? true : false);
         $customerId = $customerModel->registerCustomer($order->getMail(), md5(_COOKIE_KEY_ . time()), $shopgateCustomerItem);
     }
     /** @var CustomerCore $customer */
     $customer = new Customer($customerId);
     /**
      * prepare cart
      */
     if (!$order->getDeliveryAddress()->getPhone()) {
         $order->getDeliveryAddress()->setPhone($order->getPhone());
     }
     if (!$order->getInvoiceAddress()->getPhone()) {
         $order->getInvoiceAddress()->setPhone($order->getPhone());
     }
     $this->getCart()->id_address_delivery = $customerModel->createAddress($order->getDeliveryAddress(), $customer);
     $this->getCart()->id_address_invoice = $customerModel->createAddress($order->getInvoiceAddress(), $customer);
     $this->getCart()->id_customer = $customerId;
     // id_guest is a connection to a ps_guest entry which includes screen width etc.
     // is_guest field only exists in Prestashop 1.4.1.0 and higher
     if (version_compare(_PS_VERSION_, '1.4.1.0', '>=')) {
         $this->getCart()->id_guest = $customer->is_guest;
     }
     $this->getCart()->secure_key = $customer->secure_key;
     $this->getCart()->id_carrier = $shippingModel->getCarrierIdByApiOrder($order);
     $shopgateCustomFieldsHelper = new ShopgateCustomFieldsHelper();
     $shopgateCustomFieldsHelper->saveCustomFields($this->getCart(), $order->getCustomFields());
     $this->getCart()->add();
     /**
      * add cart items
      */
     $canCreateOrder = true;
     $errorMessages = array();
     foreach ($order->getItems() as $item) {
         list($productId, $attributeId) = ShopgateHelper::getProductIdentifiers($item);
         if ($productId == 0) {
             continue;
         }
         $updateCart = $this->getCart()->updateQty($item->getQuantity(), $productId, $attributeId, false, 'up', $this->getCart()->id_address_delivery);
         if ($updateCart !== true) {
             $canCreateOrder = false;
             $errorMessages[] = array('product_id' => $productId, 'attribute_id' => $attributeId, 'quantity' => $item->getQuantity(), 'result' => $updateCart, 'reason' => $updateCart == -1 ? 'minimum quantity not reached' : '');
         }
     }
     /**
      * coupons
      */
     foreach ($order->getExternalCoupons() as $coupon) {
         /** @var CartRuleCore $cartRule */
         $cartRule = new CartRule(CartRule::getIdByCode($coupon->getCode()));
         if (Validate::isLoadedObject($cartRule)) {
             $this->getCart()->addCartRule($cartRule->id);
             $this->getCart()->save();
         }
     }
     if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
         /**
          * this field is not available in version 1.4.x.x
          * set delivery option
          */
         $delivery_option = array($this->getCart()->id_address_delivery => $shippingModel->getCarrierIdByApiOrder($order) . ',');
         $this->getCart()->setDeliveryOption($delivery_option);
     }
     /**
      * store shopgate order
      */
     $shopgateOrderItem = new ShopgateOrderPrestashop();
     $shopgateOrderItem->fillFromOrder($this->getCart(), $order, $this->getPlugin()->getShopgateConfig()->getShopNumber());
     if (version_compare(_PS_VERSION_, '1.6.0.0', '<')) {
         $shopgateOrderItem->add();
     }
     /**
      * create order
      */
     if ($canCreateOrder) {
         /**
          * get first item from order stats
          */
         $this->getCart()->save();
         $idOrderState = reset($paymentModel->getOrderStateId($order));
         $validateOder = $this->getModule()->validateOrder($this->getCart()->id, $idOrderState, $this->getCart()->getOrderTotal(true, defined('Cart::BOTH') ? Cart::BOTH : 3), $paymentModel->getPaymentTitleByKey($order->getPaymentMethod()), null, array(), null, false, $this->getCart()->secure_key);
         if (version_compare(_PS_VERSION_, '1.5.0.0', '<') && (int) $this->getModule()->currentOrder > 0 && $order->getShippingType() != ShopgateShipping::DEFAULT_PLUGIN_API_KEY && $order->getShippingInfos()->getAmount() > 0) {
             ShopgateLogger::log('PS < 1.5.0.0: update shipping and payment cost', ShopgateLogger::LOGTYPE_DEBUG);
             // in versions below 1.5.0.0 the shipping and payment costs must be updated after the order was imported
             /** @var OrderCore $updateShopgateOrder */
             $updateShopgateOrder = new Order($this->getModule()->currentOrder);
             $updateShopgateOrder->total_shipping = $order->getAmountShipping() + $order->getAmountShopPayment();
             $updateShopgateOrder->total_paid += $order->getAmountShipping() + $order->getAmountShopPayment();
             $updateShopgateOrder->total_paid_real += $order->getAmountShipping() + $order->getAmountShopPayment();
             $updateShopgateOrder->update();
         }
         /**
          * update shopgate order
          */
         if ($validateOder) {
             $shopgateOrderItem->id_order = $this->getModule()->currentOrder;
             $shopgateOrderItem->status = 1;
             $shopgateOrderItem->save();
             return array('external_order_id' => $shopgateOrderItem->id_order, 'external_order_number' => $shopgateOrderItem->id_order);
         }
     }
     $shopgateOrderItem->delete();
     throw new ShopgateLibraryException(ShopgateLibraryException::UNKNOWN_ERROR_CODE, 'Unable to create order:' . print_r($errorMessages, true), true);
 }
 public function unistallExternalCarrier($id_carrier)
 {
     if ((int) $id_carrier) {
         $Carrier1 = new Carrier((int) $id_carrier);
         // If external carrier is default set other one as default
         if (Configuration::get('PS_CARRIER_DEFAULT') == (int) $Carrier1->id) {
             $this->module->_errors[] = 'Please select different default carrier before uninstall';
             return false;
         }
         // Then delete Carrier
         $Carrier1->deleted = 1;
         if (!$Carrier1->update()) {
             return false;
         }
     }
     return true;
 }
 public function uninstall()
 {
     global $cookie;
     if (!parent::uninstall() or !Db::getInstance()->Execute('DROP TABLE IF EXISTS`' . _DB_PREFIX_ . 'socolissimo_delivery_info`') or !$this->unregisterHook('extraCarrier') or !$this->unregisterHook('payment') or !$this->unregisterHook('AdminOrder') or !Configuration::deleteByName('SOCOLISSIMO_ID') or !$this->unregisterHook('newOrder') or !$this->unregisterHook('updateCarrier') or !Configuration::deleteByName('SOCOLISSIMO_KEY') or !Configuration::deleteByName('SOCOLISSIMO_URL') or !Configuration::deleteByName('SOCOLISSIMO_EXP_BEL') or !Configuration::deleteByName('SOCOLISSIMO_VERSION') or !Configuration::deleteByName('SOCOLISSIMO_SUP_BELG') or !Configuration::deleteByName('SOCOLISSIMO_COST_SELLER') or !Configuration::deleteByName('SOCOLISSIMO_OVERCOST') or !Configuration::deleteByName('SOCOLISSIMO_PREPARATION_TIME') or !Configuration::deleteByName('SOCOLISSIMO_CARRIER_ID') or !Configuration::deleteByName('SOCOLISSIMO_PRODUCT_ID') or !Configuration::deleteByName('SOCOLISSIMO_CAT_ID') or !Configuration::deleteByName('SOCOLISSIMO_SUP') or !Configuration::deleteByName('SOCOLISSIMO_SUP_URL') or !Configuration::deleteByName('SOCOLISSIMO_OVERCOST_TAX')) {
         return false;
     }
     //Delete So Carrier
     $soCarrier = new Carrier(intval(Configuration::get('SOCOLISSIMO_CARRIER_ID')));
     //if socolissimo carrier is default set other one as default
     if (Configuration::get('PS_CARRIER_DEFAULT') == intval($soCarrier->id)) {
         $carriersD = Carrier::getCarriers(intval($cookie->id_lang));
         foreach ($carriersD as $carrierD) {
             if ($carrierD['active'] and !$carrierD['deleted'] and $carrierD['name'] != $this->_config['name']) {
                 Configuration::updateValue('PS_CARRIER_DEFAULT', $carrierD['id_carrier']);
             }
         }
     }
     //save old carrier id
     Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_HIST', Configuration::get('SOCOLISSIMO_CARRIER_ID_HIST') . '|' . intval($soCarrier->id));
     $soCarrier->deleted = 1;
     if (!$soCarrier->update()) {
         return false;
     }
     //Delete So Carrier
     $soCarrier = new Carrier(intval(Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER')));
     //if socolissimo carrier is default set other one as default
     if (Configuration::get('PS_CARRIER_DEFAULT') == intval($soCarrier->id)) {
         $carriersD = Carrier::getCarriers(intval($cookie->id_lang));
         foreach ($carriersD as $carrierD) {
             if ($carrierD['active'] and !$carrierD['deleted'] and $carrierD['name'] != $this->_config['name']) {
                 Configuration::updateValue('PS_CARRIER_DEFAULT', $carrierD['id_carrier']);
             }
         }
     }
     //save old carrier id
     Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_HIST', Configuration::get('SOCOLISSIMO_CARRIER_ID_HIST') . '|' . intval($soCarrier->id));
     $soCarrier->deleted = 1;
     if (!$soCarrier->update()) {
         return false;
     }
     //delete hidden category and product overcost
     if (Configuration::get('SOCOLISSIMO_CAT_ID') != '' and Configuration::get('SOCOLISSIMO_PRODUCT_ID') != '') {
         $category = new Category(Configuration::get('SOCOLISSIMO_CAT_ID'));
         $product = new Product(Configuration::get('SOCOLISSIMO_PRODUCT_ID'));
         $category->delete();
         $product->delete();
     }
     return true;
 }