/**
  * Get shipping prices.
  *
  * @return SimpleXMLElement
  */
 public function get_shipping()
 {
     $shipping = null;
     // Checks if service and postcode are empty.
     if (!$this->is_setted()) {
         return $values;
     }
     if (!is_null($this->package)) {
         $package = $this->package->get_data();
         $this->height = $package['height'];
         $this->width = $package['width'];
         $this->length = $package['length'];
         $this->weight = $package['weight'];
     }
     if ('yes' == $this->debug) {
         if (!empty($package)) {
             $package = array('weight' => $this->weight, 'height' => $this->height, 'width' => $this->width, 'length' => $this->length);
         }
         $this->log->add($this->id, 'Weight and cubage of the order: ' . print_r($package, true));
     }
     $args = apply_filters('woocommerce_correios_shipping_args', array('nCdServico' => $this->service, 'nCdEmpresa' => apply_filters('woocommerce_correios_login', '', $this->id), 'sDsSenha' => apply_filters('woocommerce_correios_password', '', $this->id), 'sCepDestino' => wc_correios_sanitize_postcode($this->destination_postcode), 'sCepOrigem' => wc_correios_sanitize_postcode($this->get_origin_postcode()), 'nVlAltura' => $this->float_to_string($this->height), 'nVlLargura' => $this->float_to_string($this->width), 'nVlDiametro' => $this->float_to_string($this->diameter), 'nVlComprimento' => $this->float_to_string($this->length), 'nVlPeso' => $this->float_to_string($this->weight), 'nCdFormato' => $this->format, 'sCdMaoPropria' => apply_filters('woocommerce_correios_own_hands', 'N', $this->id), 'nVlValorDeclarado' => round(number_format($this->declared_value, 2, '.', '')), 'sCdAvisoRecebimento' => apply_filters('woocommerce_correios_receipt_notice', 'N', $this->id), 'StrRetorno' => 'xml'), $this->id);
     $url = add_query_arg($args, $this->get_webservice_url());
     if ('yes' == $this->debug) {
         $this->log->add($this->id, 'Requesting Correios WebServices: ' . $url);
     }
     // Gets the WebServices response.
     $response = wp_safe_remote_get($url, array('timeout' => 30));
     if (is_wp_error($response)) {
         if ('yes' == $this->debug) {
             $this->log->add($this->id, 'WP_Error: ' . $response->get_error_message());
         }
     } elseif ($response['response']['code'] >= 200 && $response['response']['code'] < 300) {
         try {
             $result = wc_correios_safe_load_xml($response['body'], LIBXML_NOCDATA);
         } catch (Exception $e) {
             if ('yes' == $this->debug) {
                 $this->log->add($this->id, 'Correios WebServices invalid XML: ' . $e->getMessage());
             }
         }
         if (isset($result->cServico)) {
             $service = $result->cServico;
             if ('yes' == $this->debug) {
                 $this->log->add($this->id, 'Correios WebServices response: ' . print_r($service, true));
             }
             $shipping = $service;
         }
     } else {
         if ('yes' == $this->debug) {
             $this->log->add($this->id, 'Error accessing the Correios WebServices: ' . print_r($response, true));
         }
     }
     return $shipping;
 }
 /**
  * Get shipping prices.
  *
  * @return SimpleXMLElement
  */
 public function get_shipping()
 {
     $shipping = null;
     // Checks if services and postcode is empty.
     if (!$this->is_setted()) {
         return $values;
     }
     if (!is_null($this->package)) {
         $package = $this->package->get_data();
         $this->height = $package['height'];
         $this->width = $package['width'];
         $this->length = $package['length'];
         $this->weight = $package['weight'];
     }
     if ('yes' == $this->debug) {
         if (!empty($package)) {
             $package = array('weight' => $this->weight, 'height' => $this->height, 'width' => $this->width, 'length' => $this->length);
         }
         $this->log->add($this->id, 'Weight and cubage of the order: ' . print_r($package, true));
     }
     $args = apply_filters('woocommerce_correios_international_shipping_args', array('tipoConsulta' => 'Geral', 'especif' => $this->service, 'uforigem' => '', 'localidade' => '', 'pais' => '', 'altura' => $this->float_to_string($this->height), 'largura' => $this->float_to_string($this->width), 'profundidade' => $this->float_to_string($this->length), 'peso' => $this->float_to_string($this->weight), 'reset' => 'true'), $this->id);
     $url = add_query_arg($args, $this->get_webservice_url());
     if ('yes' == $this->debug) {
         $this->log->add($this->id, 'Requesting Correios WebServices: ' . $url);
     }
     // Gets the WebServices response.
     $response = wp_safe_remote_get($url, array('timeout' => 30));
     if (is_wp_error($response)) {
         if ('yes' == $this->debug) {
             $this->log->add($this->id, 'WP_Error: ' . $response->get_error_message());
         }
     } elseif ($response['response']['code'] >= 200 && $response['response']['code'] < 300) {
         try {
             $result = wc_correios_safe_load_xml($response['body'], LIBXML_NOCDATA);
         } catch (Exception $e) {
             if ('yes' == $this->debug) {
                 $this->log->add($this->id, 'Correios WebServices invalid XML: ' . $e->getMessage());
             }
         }
         if (isset($result->exporta_facil->tipo_servico)) {
             $service = $result->exporta_facil->tipo_servico;
             if ('yes' == $this->debug) {
                 $this->log->add($this->id, 'Correios WebServices response: ' . print_r($service, true));
             }
             $shipping = $service;
         }
     } else {
         if ('yes' == $this->debug) {
             $this->log->add($this->id, 'Error accessing the Correios WebServices: ' . print_r($response, true));
         }
     }
     return $shipping;
 }