Freight calculation Post Office + PHP

Asked

Viewed 671 times

1

How is the freight values calculated in case the user selects more than one product in a virtual store? When registering a product, we are giving the option to the customer to put the length, height, width, diameter and weight per product. In PHP picked this way before calculating shipping:

$parametros['nVlComprimento'] = '35';
$parametros['nVlAltura'] = '21';
$parametros['nVlLargura'] = '13';
$parametros['nVlDiametro'] = '0';

My only question is how is it calculated? I am currently calculating the quantity of products * the freight value that is generated by the API I am using, but I would not have to calculate the above values also in case the customer chooses another product?

  • 1

    I worked with Loja Virtual, I used the Post Office API to calculate, sent the data as weight etc and the mail returned the value. It depends on the size, weight of the product, location, etc. For example: https://github.com/newerton/api-correios/blob/master/Correios.php

1 answer

1


I calculate separately the freight for each product. As if I would have a package for each. Then we add all the results.

As the freight of the post office is based by volume and weight, there is no way to be sure of the exact value in case of more than one product, since we have no way of knowing the size of the final box where everything will be placed (if put everything in one box).

  • Thank you all.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.