This commit is contained in:
Michael RICOIS 2018-01-15 15:38:14 +01:00
parent 637fea818f
commit e459ed17c3

View File

@ -120,105 +120,8 @@ if(($id_order = (int) Tools::getValue('id_order'))
$invoice_address = new Address($order->id_address_invoice);
$delivery_address = new Address($order->id_address_delivery);
/*if($delivery_address->id_country == 8) {
$replace_tests = array(
'-S-' => ' SUR ',
'-SS-' => ' SOUS ',
' ST-' => ' SAINT ',
'-ST ' => ' SAINT ',
'-ST-' => ' SAINT ',
' STE-' => ' SAINTE ',
'-STE ' => ' SAINTE ',
'-STE ' => ' SAINTE ',
' MT-' => ' MONT ',
'-MT ' => ' MONT ',
'-MT-' => ' MONT ',
' BG-' => ' BOURG ',
'-BG ' => ' BOURG ',
'-BG-' => ' BOURG ',
' GD-' => ' GRAND ',
'-GD ' => ' GRAND ',
'-GD-' => ' GRAND ',
' GDE-' => ' GRANDE ',
'-GDE ' => ' GRANDE ',
'-GDE-' => ' GRANDE ',
' MTS-' => ' MONTS ',
'-MTS ' => ' MONTS ',
'-MTS-' => ' MONTS ',
' VX-' => ' VIEUX ',
'-VX ' => ' VIEUX ',
'-VX-' => ' VIEUX ',
' HT-' => ' HAUT ',
'-HT ' => ' HAUT ',
'-HT-' => ' HAUT ',
' BS-' => ' BAS ',
'-BS ' => ' BAS ',
'-BS-' => ' BAS ',
' S ' => ' SUR ',
' SS ' => ' SOUS ',
' ST ' => ' SAINT ',
' STE ' => ' SAINTE ',
' MT ' => ' MONT ',
' BG ' => ' BOURG ',
' GD ' => ' GRAND ',
' GDE ' => ' GRANDE ',
' MTS ' => ' MONTS ',
' VX ' => ' VIEUX ',
' HT ' => ' HAUT ',
' BS ' => ' BAS ',
' ST. ' => ' SAINT ',
);
$cities = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `city`
FROM `'._DB_PREFIX_.'france_postcode`
WHERE `postcode` = "'.pSQL(trim($delivery_address->postcode)).'"
') as $row) {
$cities[] = $row['city'];
}
$found = FALSE;
if($cities) {
foreach($cities as $city) {
if(str_replace(array('\\', '-', '_', ' ', '/', '\'', '"', '«', '»', '', ' ', '.', ',',), '', strtolower(trim(stripaccents($city)))) == str_replace(array('\\', '-', '_', ' ', '/', '\'', '"', '«', '»', '', ' ', '.', ',',), '', strtolower(trim(stripaccents(preg_replace('/ C(I|E)DEX(.*)$/i', '', $delivery_address->city)))))) {
$found = TRUE;
}
}
}
if(!$found) {
foreach($cities as $city) {
$clean_city = str_replace(array('\\', '-', '_', ' ', '/', '\'', '"', '«', '»', '', ' ', '.', ',',), '', strtolower(trim(stripaccents($city))));
$clean_customer_city = str_replace(array('\\', '-', '_', ' ', '/', '\'', '"', '«', '»', '', ' ', '.', ',',), '', strtolower(trim(str_ireplace('/', ' SUR ', str_ireplace(' S/', ' SUR ', str_ireplace(array_keys($replace_tests), array_values($replace_tests), stripaccents(' '.preg_replace('/ C(I|E)DEX(.*)$/i', '', $delivery_address->city).' ')))))));
if($clean_city === $clean_customer_city
|| $clean_city === 'le'.$clean_customer_city
|| $clean_city === 'la'.$clean_customer_city
|| $clean_city === 'les'.$clean_customer_city
|| $clean_city === 'l'.$clean_customer_city
|| 'le'.$clean_city === $clean_customer_city
|| 'la'.$clean_city === $clean_customer_city
|| 'les'.$clean_city === $clean_customer_city
|| 'l'.$clean_city === $clean_customer_city) {
$found = TRUE;
}
}
}
$france_address_error = !$found;
$france_address_suggestions = array();
if($france_address_error) {
$france_address_suggestions = Db::getInstance()->ExecuteS('
SELECT `postcode`, `city`
FROM `'._DB_PREFIX_.'france_postcode`
WHERE `postcode` = "'.pSQL($delivery_address->postcode).'"
OR `city` = "'.pSQL($delivery_address->city).'"
GROUP BY `postcode`, `city`
');
}
} else {*/
$france_address_error = FALSE;
$france_address_suggestions = array();
/*}*/
$id_order_details = array();
@ -287,21 +190,6 @@ if(($id_order = (int) Tools::getValue('id_order'))
$p['image'] = '//'.$link->getImageLink('image', $p['product_id'].'-'.$p['id_image'], 'home');
/*$shipping = Db::getInstance()->getRow('
SELECT s.`id_shipping`, s.`id_sale`
FROM `'._DB_PREFIX_.'privatesale_shipping_sale` s
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c
ON c.`id_sale` = s.`id_sale`
WHERE c.`id_product` = '.(int) $p['product_id'].'
');
if(!$shipping) {
$p['id_shipping'] = 1; // PSS
$p['id_sale'] = 999999;
} else {
$p['id_shipping'] = $shipping['id_shipping'];
$p['id_sale'] = $shipping['id_sale'];
}*/
$p['id_shipping'] = 1;
$p['id_sale'] = (int) Db::getInstance()->getValue('
SELECT `id_sale`