PHP Classes

Calcular Frete Correios PHP Class: Calculate shipping costs for the Correios services

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-10-30 (11 months ago) RSS 2.0 feedStarStarStarStar 61%Total: 107 All time: 9,683 This week: 43Up
Version License PHP version Categories
frete-correios 1.0.4BSD License5PHP 5, E-Commerce, Web services
Description 

Author

This package is specific mainly for applications used in Brazil Brazil .

This class can calculate the shipping costs for sending parcels using the Correios of Brazil post office company services.

It can send HTTP requests to the Correios Web services API to request quotes for sending parcels using different shipping options using Correios services.

The class supports calculating shipping costs for either national or international destinations.

Em Português:

Esta classe pode calcular os custos de envio para o envio de encomendas usando os serviços dos Correios do Brasil.

A classe pode enviar pedidos HTTP para a API de Web services dos Correios para solicitar orçamentos para envio de encomendas usando diferentes opções de envio usando os serviços dos Correios.

A classe suporta o cálculo dos custos de envio para destinos nacionais ou internacionais.

Picture of Manuel Lemos
  Performance   Level  
Name: Manuel Lemos is available for providing paid consulting. Contact Manuel Lemos .
Classes: 45 packages by
Country: Portugal Portugal
Age: 55
All time rank: 1
Week rank: 5 Down1 in Portugal Portugal Equal

Example

<?php
/*
 * correios_calcula_frete_nacional.php
 *
 * @(#) $Id: correios_calcula_frete_nacional.php,v 1.4 2023/10/29 10:53:35 mlemos Exp $
 *
 */

   
require('http.php');
    require(
'sasl.php');
    require(
'filecacheclass.php');
    require(
'correios_calcula_frete.php');

   
Header('Content-Type: text/html; charset=utf-8');

   
$correios = new correios_calcula_frete_class;
   
$correios->depurar = true;
   
$correios->depurar_http = false;
   
$correios->depurar_respostas_de_http = false;
   
$correios->depurar_em_html = true;
   
$correios->registrar_depuracao = false;
   
$correios->arquivo_de_registro_de_depuracao = '';
   
$correios->diretorio_de_cache = '';
   
$correios->api_user = '';
   
$correios->api_password = '';
   
$correios->cartao_de_postagem = '';
   
$parameters = array(
       
"TiposDeServico"=>array(
           
'Correios Mini Envios',
           
'SEDEX',
           
'PAC'
       
),
       
"CEPDeOrigem"=>"01310200",
       
"Peso"=>200,
       
"CEPDeDestino"=>"82220-000",
       
"TipoDeEmbalagem"=>"Caixa",
       
"Profundidade"=>32,
       
"Largura"=>22,
       
"Altura"=>15,
    );
   
$success = $correios->CalculaFreteNacional($parameters);
?>
<html>
<head>
<title>Cálculo de Frete Nacional dos Correios</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1 style="text-align: center">Cálculo de Frete Nacional dos Correios</h1>
<hr />
<?php
   
if($success)
    {
        echo
'<pre>', nl2br(print_r($parameters['Opcoes'], 1)), '</pre>';
    }
    else
    {
?>
<h2 style="text-align: center">Erro: <?php echo $correios->erro ?></h2>
<?php
   
}
?>
<hr />
</body>
</html>


  Files folder image Files (4)  
File Role Description
Plain text file correios_calcula_frete.php Class Classe para obter os valores do frete de encomendas enviadas pelos Correios
Accessible without login Plain text file correios_calcula_frete_internacional.php Example Exemplo para obter os valores do frete internacional de encomendas enviadas pelos Correios
Accessible without login Plain text file correios_calcula_frete_nacional.php Example Exemplo para obter os valores do frete nacional de encomendas enviadas pelos Correios
Accessible without login Plain text file verificar_frete_internacional.php Example Script de verificacao da possibilidade de entrega de multiplos destinatarios de uma vez so

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadfrete-correios-2023-10-30.zip 9KB
Downloadfrete-correios-2023-10-30.tar.gz 7KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Generic XML parser class Download .zip .tar.gz Parse the response for Correios API to get shipping costs for national deliveries Conditional
Simple Authentication and Security Layer Download .zip .tar.gz Access pages that require authentication Conditional
PHP HTTP protocol client Download .zip .tar.gz Access Correios API via HTTP Required
File cache class Download .zip .tar.gz Cache the responses of Correios API to avoid the delay of calling the API multiple times to obtain the same responses Required
 Version Control Unique User Downloads Download Rankings  
 100%
Total:107
This week:0
All time:9,683
This week:43Up
User Ratings User Comments (1)
 All time
Utility:91%StarStarStarStarStar
Consistency:66%StarStarStarStar
Documentation:-
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:61%StarStarStarStar
Rank:1023
 
Useful and comprehensive, but I missed annotations on code an...
3 years ago (Carlos Artur Curvelo da Matos)
50%StarStarStar