Calcular Preços e Prazos sem utilizar SIGEP
Closed this issue · 4 comments
Ao tentar realizar uma consulta sem passar um contrato, recebo este erro, é possível fazer isso com essa lib?
There is no service with the code "0".
Para utilizar o calculo de frete sem usuario/senha tive que utilizar essa lib:
https://github.com/flyingluscas/correios-php
<?php
$correiosClient = new Client();
$allServices = ServicoDePostagem::getAll();
$services_active = $correios->services_active ? explode(',', $correios->services_active) : [];
if (!$services_active) {
$services_active = $allServices;
} else {
$services_active = array_filter($allServices, function($service) use ($services_active) {
if (in_array($service->getCodigo(), $services_active)) {
return $service;
}
});
}
$freight = $correiosClient->freight()
->origin($correios->defaultZip())
->destination($request->zip_code)
->services(Service::PAC, Service::SEDEX, Service::SEDEX_10, Service::SEDEX_HOJE);
if ($correios->extra_declared_amount) {
$amount = $request->amount;
if (!$amount OR $amount < Correios::MINIMUM_PRICE) {
$amount = Correios::MINIMUM_PRICE;
}
$freight->declaredValue($amount);
}
if ($correios->extra_maos_proprias) {
$freight->useOwnHand(true);
}
if ($correios->extra_delivery_alert) {
$freight->useDeliveryAlert(true);
}
$qty = 1;
$methods = $freight->item(
$request->default_width,
$request->default_height,
$request->default_length,
$request->default_weight/1000,
$qty
)->calculate(); // largura, altura, comprimento, peso e quantidade
Seria possível realizar o mesmo procedimento via stavarengo/php-sigep?
Pois alguns clientes não possuem contratos e outros sim. E ao tentar recebo o erro acima.
Seria algo similar ao https://github.com/stavarengo/php-sigep/blob/d0b4ef92e79c5ee8703e1d0c0c755e239af552a9/exemplos/calcPrecoPrazo.php porém o "AccessData" vazio não rola.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.