get_billing_phone(); } else { $phone = $order->get_shipping_phone() == '' ? $order->get_billing_phone() : $order->get_shipping_phone(); } $phone = Utils::cleanTelephoneNumber($phone); // sólo establecer phone_mobile con el phone si: // - phone tiene 9 dígitos // - phone empieza por 6, 7, 9 if ( strlen($phone)==9 && ( substr($phone, 0, 1)=='6' || substr($phone, 0, 1)=='7' || substr($phone, 0, 1)=='9' ) ) { $phone_mobile = $phone; } else { $phone_mobile = ''; } return array( 'id_order' => $id_order, 'id_cart' => $order->get_cart_hash(), 'customer_firstname' => $order->get_shipping_first_name(), 'customer_lastname' => $order->get_shipping_last_name(), 'customer_dni' => CorreosOficialOrder::getRealDnI($id_order), 'delivery_address' => $order->get_shipping_address_1(), 'delivery_address2' => $order->get_shipping_address_2(), 'delivery_city' => $order->get_shipping_city(), 'delivery_postcode' => $order->get_shipping_postcode(), 'delivery_phone' => $phone, 'phone' => $phone, 'phone_mobile' => $phone_mobile, 'customer_email' => $order->get_billing_email(), 'delivery_country_iso' => $order->get_shipping_country(), ); } public static function getRequestRecord( $id_order ) { $query = SELECT . DB_PREFIX . 'correos_oficial_requests cor LEFT JOIN ' . DB_PREFIX . "orders po ON (cor.id_cart = po.id_cart) WHERE po.id_order=$id_order"; return self::launchQuery($query, true); } public static function getCorreosOrder( $id_order ) { if (!empty($id_order)) { $query = SELECT . DB_PREFIX . 'correos_oficial_orders coo LEFT JOIN ' . DB_PREFIX . "correos_oficial_products cop ON (cop.id = coo.id_product) WHERE id_order = $id_order"; $dao = new CorreosOficialDAO(); $record = $dao->getRecordsWithQuery($query, true); if ($record) { return $record[0]; } } } public static function getCorreosPackages( $id_order ) { $query = SELECT . DB_PREFIX . 'correos_oficial_orders coo LEFT JOIN ' . DB_PREFIX . "correos_oficial_saved_orders coso ON (coso.exp_number = coo.shipping_number) WHERE coo.id_order=$id_order"; $dao = new CorreosOficialDAO(); return $dao->getRecordsWithQuery($query, true); } public static function getCorreosReturn( $id_order ) { $query = SELECT . DB_PREFIX . "correos_oficial_returns WHERE id_order = $id_order"; $result = self::launchQuery($query, true); if ($result) { return $result[0]; } } public static function getCorreosPickupReturn( $id_order ) { $query = SELECT . DB_PREFIX . "correos_oficial_pickups_returns WHERE id_order = $id_order"; $result = self::launchQuery($query, true); if ($result) { return $result[0]; } } public static function getCorreosPackagesReturn( $id_order ) { $query = SELECT . DB_PREFIX . 'correos_oficial_returns cor LEFT JOIN ' . DB_PREFIX . "correos_oficial_saved_returns cosr ON (cosr.exp_number = cor.shipping_number) WHERE cor.id_order=$id_order"; return self::launchQuery($query, true); } public static function launchQuery( $query, $as_array = false ) { $dao = new CorreosOficialDao(); return $dao->getRecordsWithQuery($query, $as_array); } }