id_customer); $dst_address = new Address($order->id_address_delivery); $dst_country = new Country($dst_address->id_country); $langs = array( 1 => 'EN', 2 => 'FR', 3 => 'ES', 5 => 'IT', 6 => 'EN', ); $dst_address = array( 'companyName' => '', 'lastName' => '', 'firstName' => '', 'line0' => '', 'line1' => '', 'line2' => '', 'line3' => '', 'countryCode' => '', 'city' => '', 'zipCode' => '', 'phoneNumber' => '', 'mobileNumber' => '', 'doorCode1' => '', 'doorCode2' => '', 'email' => '', 'intercom' => '', 'language' => $langs[(int) $order->id_lang], ); $prid = ''; $instructions = ''; $unicode_ack = json_decode('"\u0006"'); $unicode_ack2 = json_decode('"\u00ad"'); if(Module::isInstalled('socolissimo') && ($so_data = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_.'socolissimo_delivery_info` WHERE `id_cart` = '.(int) $order->id_cart.' AND `id_customer` = '.(int) $order->id_customer.' ')) && ( (strpos(Db::getInstance()->getValue(' SELECT `name` FROM `'._DB_PREFIX_.'carrier` WHERE `id_carrier` = '.(int) $order->id_carrier.' '), 'La Poste') !== FALSE) || (strpos(Db::getInstance()->getValue(' SELECT `name` FROM `'._DB_PREFIX_.'carrier` WHERE `id_carrier` = '.(int) $order->id_carrier.' '), 'Colissimo') !== FALSE) )) { $product_type = $so_data['delivery_mode']; if($product_type == 'BOM') { $product_type = 'DOM'; } if($so_data['cecountry'] == 'ES' && $product_type == 'DOM') { $product_type = 'DOS'; } if(!in_array($so_data['cecountry'], array('ES', 'BE', 'AD', 'MC', 'FR', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) { $product_type = 'DOS'; } if($so_data['cecountry'] == 'IT'){ $product_type = 'COLI'; } $dst_address['email'] = $so_data['ceemail']; if(empty($dst_address['email'])) { $dst_address['email'] = $dst_customer->email; } if(!empty($so_data['cename'])) { $dst_address['lastName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','İ'), array(' ', '', '', '', 'a', 'a','a','A','l','i'), $so_data['cename']), 0, 35); } else { $dst_address['lastName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','İ'), array(' ', '', '', '', 'a', 'a','a','A','l','i'), $so_data['prname']), 0, 35); } if(!empty($so_data['cefirstname'])) { $dst_address['firstName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['cefirstname']), 0, 29); } else { $dst_address['firstName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['prfirstname']), 0, 29); } if(!empty($so_data['cecompanyname'])) { $dst_address['companyName'] = mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ'), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i'), $so_data['cecompanyname']), 0, 35); } $address_lines = array(); for($i = 1; $i < 5; $i++) { if(($line = (string) mb_substr($so_data['pradress'.$i], 0, 32)) != '') { $address_lines[] = trim($line); } } if(count($address_lines) == 1) { $dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]); } elseif(count($address_lines) == 2) { $dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]); $dst_address['line3'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[1]); } elseif(count($address_lines) == 3) { $dst_address['line0'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]); $dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[1]); $dst_address['line3'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[2]); } else { $dst_address['line0'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[0]); $dst_address['line1'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[1]); $dst_address['line2'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[2]); $dst_address['line3'] = str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª'), array(' ', '', '', '', 'a', 'a','a'), $address_lines[3]); } $dst_address['countryCode'] = $so_data['cecountry']; if(strtolower($so_data['cecountry']) == 'sl') { $dst_address['zipCode'] = (string) str_ireplace(array('SI-', 'SL-'), '', mb_substr($so_data['przipcode'], 0, 5)); } elseif(strtolower($so_data['cecountry']) == 'pt') { $dst_address['zipCode'] = (string) $so_data['przipcode']; } else { $dst_address['zipCode'] = (string) mb_substr($so_data['przipcode'], 0, 5); } $dst_address['city'] = (string) mb_substr($so_data['prtown'], 0, 35); $dst_address['mobileNumber'] = (string) mb_substr(str_replace(array('.','°', '|', ' ', '',"/"),'',$so_data['cephonenumber']), 0, 32); if(strlen($dst_address['mobileNumber']) > 10) { if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $dst_address['mobileNumber'])) { $dst_address['mobileNumber'] = '0'.mb_substr(mb_substr($dst_address['mobileNumber'], -10), 1); } if(strtolower($so_data['cecountry']) == 'be' && preg_match('/^(0032|32)[0-9]{9,10}$/', $dst_address['mobileNumber'])) { $dst_address['mobileNumber'] = '+32'.mb_substr(mb_substr($dst_address['mobileNumber'], -10), 1); } } elseif(strtolower($so_data['cecountry']) == 'fr' && preg_match('/^[0-9]{9,10}$/', $dst_address['mobileNumber'])) { if(strlen($dst_address['mobileNumber']) == 9) { $dst_address['mobileNumber'] = '0'.$dst_address['mobileNumber']; } elseif(strlen($dst_address['mobileNumber']) == 10) { $dst_address['mobileNumber'] = '0'.mb_substr(mb_substr($dst_address['mobileNumber'], -10), 1); } } elseif(strtolower($so_data['cecountry']) == 'be' && preg_match('/^[0-9]{9,10}$/', $dst_address['mobileNumber'])) { if(strlen($dst_address['mobileNumber']) == 9) { $dst_address['mobileNumber'] = '+32'.$dst_address['mobileNumber']; } elseif(strlen($dst_address['mobileNumber']) == 10) { $dst_address['mobileNumber'] = '+32'.mb_substr(mb_substr($dst_address['mobileNumber'], -10), 1); } } if(strtolower($so_data['cecountry']) == 'fr' && mb_substr($dst_address['mobileNumber'], 0, 2) != '06' && mb_substr($dst_address['mobileNumber'], 0, 2) != '07') { $dst_address['mobileNumber'] = '0600000000'; } if(($doorcode = (string) mb_substr($so_data['cedoorcode1'], 0, 8)) != '') { $dst_address['doorCode1'] = (string) mb_substr($so_data['cedoorcode1'], 0, 8); } if(($doorcode = (string) mb_substr($so_data['cedoorcode2'], 8, 8)) != '') { $dst_address['doorCode2'] = (string) mb_substr($so_data['cedoorcode1'], 8, 8); } $instructions = trim(str_replace(array('°', '|', ' ', '', "\n", "\r"), ' ', (string) $so_data['cedeliveryinformation'])); $prid = $so_data['prid']; } else { $dst_address['companyName'] = (string) mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ', $unicode_ack, $unicode_ack2), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i',' ',' '), $dst_address->company), 0, 35); $dst_address['lastName'] = (string) mb_substr(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ', $unicode_ack, $unicode_ack2), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i',' ',' '), $dst_address->firstname), 0, 35); $dst_address['firstName'] = (string) mb_substr(strtoupper(str_replace(array('°', 'º', 'º', 'º', 'ª', 'ā','ª','Á','ł','','İ', $unicode_ack, $unicode_ack2), array(' ', '', '', '', 'a', 'a','a','A','l',' ','i',' ',' '), $dst_address->lastname)), 0, 29); $dst_address['email'] = (string) $dst_customer->email; if($dst_address->id_country == 193) { $dst_address['zipCode'] = mb_substr((string) str_ireplace(array('SI-', 'SL-'), '', $dst_address->postcode), 0, 5); } else { $dst_address['zipCode'] = mb_substr((string) str_replace(array(' ', '-'), '', $dst_address->postcode), 0, 5); } $dst_address['city'] = (string) mb_substr(strtoupper($dst_address->city), 0, 35); if(in_array($dst_country->iso_code, array('GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) { $dst_address['countryCode'] = 'FR'; } else { $dst_address['countryCode'] = (string) $dst_country->iso_code; } $dst_address['line2'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), (string) $dst_address->address1); $dst_address['line3'] = str_replace(array('º', 'º', 'º', 'ª',), array('', '', '', 'a'), (string) $dst_address->address2); $instructions = trim(str_replace(array('°', '|', ' ', '', "\n", "\r"), ' ', (string) $dst_address->other)); if(in_array($dst_country->iso_code, array('FR', 'AD', 'MC', 'GP', 'RE', 'MQ', 'YT', 'NC', 'PM', 'GF'))) { $dst_address->phone = ($dst_address->phone != ''? (string) str_replace(array('.','°', '|', ' ', '',"/"),'',$dst_address->phone) : ''); $dst_address->phone_mobile = ($dst_address->phone_mobile != ''? (string) str_replace(array('.','°', '|', ' ', '',"/"),'',$dst_address->phone_mobile) : ''); if($dst_address->phone != '' && preg_match('/^0[67][0-9]+$/', $dst_address->phone)) { $dst_address['phoneNumber'] = (string) $dst_address->phone; } elseif($dst_address->phone_mobile != '' && preg_match('/^0[67][0-9]+$/', $dst_address->phone_mobile)) { $dst_address['phoneNumber'] = (string) $dst_address->phone_mobile; } if(strlen($dst_address['phoneNumber']) > 10) { if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $dst_address['phoneNumber'])) { $dst_address['phoneNumber'] = '0'.mb_substr(mb_substr($dst_address['phoneNumber'], -10), 1); } } if(strlen($dst_address['mobileNumber']) > 10) { if(preg_match('/^(0033|\+33|33)[0-9]{9,10}$/', $dst_address['mobileNumber'])) { $dst_address['mobileNumber'] = '0'.mb_substr(mb_substr($dst_address['mobileNumber'], -10), 1); } } } else { if($dst_country->iso_code == 'BE') { if($dst_address->phone != '') { $dst_address['phoneNumber'] = (string) $dst_address->phone; } else { $dst_address['phoneNumber'] = (string) $dst_address->phone_mobile; } $dst_address['mobileNumber'] = ''; } else { if($dst_address->phone != '') { $dst_address['phoneNumber'] = (string) $dst_address->phone; } if($dst_address->phone_mobile != '') { $dst_address['mobileNumber'] = (string) $dst_address->phone_mobile; } } } if($dst_country->iso_code == 'FR' || $dst_country->iso_code == 'MC' || $dst_country->iso_code == 'BE') { //$product_type = 'COLD'; // Amené a disparaitre $product_type = 'DOM'; } else { $product_type = 'COLI'; } } } echo '
';var_dump($product_type, $dst_address);echo '';die();