This is an easy to use package to calculate the cross price.
- Amazon
Require using Composer:
$ composer install
include_once './vendor/autoload.php';
use \Coccoc\ShippingService\Providers\AmazonProvider;
use \Coccoc\ShippingService\Services\OrderService;
use \Coccoc\ShippingService\Product;
$products = array(
array(
'price' => 10,
'weight' => 120, // gram
'width' => 100, // cm
'height' => 120, // cm
'depth' => 10,
),
array(
'price' => 20,
'weight' => 150, // gram
'width' => 110, // cm
'height' => 120, // cm
'depth' => 8,
)
);
$provider = new AmazonProvider();
$order_service = new OrderService($provider);
foreach ($products as $_product) {
$product = new Product();
$product->setPrice($_product['price']);
$product->setWeight($_product['weight']);
$product->setWidth($_product['width']);
$product->setHeight($_product['height']);
$product->setDepth($_product['depth']);
$order_service->setProduct($product);
}
$order_gross_price = $order_service->handle();
$ ./vendor/bin/phpunit --testdox --coverage-text --coverage-clover=coverage.clover
or using this command
$ composer test