4
Colleagues.
When calculating the cart freight, it is returning as follows:
I wonder, how do I get only the value 24.90? Because I need to add to the value of the cart. See below the reference codes:
PHP
$parametros = http_build_query($parametros);
$url = 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx';
$curl = curl_init($url.'?'.$parametros);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$dados = curl_exec($curl);
$dados = simplexml_load_string($dados);
foreach($dados->cServico as $linhas) {
if($linhas->Erro == 0) {
echo str_replace(",",".",$linhas->Valor) .'</br>';
echo "<strong>Prazo de entrega:</strong> ".$linhas->PrazoEntrega. "Dias </br>";
}else {
echo $linhas->MsgErro;
}
JQUERY
ajax1.onreadystatechange = function() {
if (ajax1.readyState == 4) {
document.getElementById("result").innerHTML = ajax1.responseText;
valorFrete = document.getElementById("result").innerHTML;
vv = document.getElementById("total").innerHTML + valorFrete;
valorTotal = document.getElementById("total").innerHTML = vv.toFixed(2);
} else {
document.getElementById("result").innerHTML = "Aguarde, calculando...";
}
}