PHP code example of the-courier-guy / common
1. Go to this page and download the library: Download the-courier-guy/common library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
the-courier-guy / common example snippets
public function __construct(
string $productId,
float $price,
?string $description,
?string $variantId,
?int $quantity = 1,
?array $dimension = null,
?array $options = []
)
php
use TCG_Common\Models\Product;
$product300g = new Product(
'product-300g',
10.0,
'Product 300g',
'variant-300g',
7,
[
'length' => 0,
'width' => 0,
'height' => 0,
'mass' => 0.3, // 300g
],
);
[
'id' => 1,
'length' => 50.0,
'width' => 40.0,
'height' => 30.0,
'max_weight' => 2.0, // kg
'volume' => 50 * 40 * 30,
'dimension' => [
'length' => 50,
'width' => 40,
'height' => 30,
'volume' => 50 * 40 * 30,
],
],
php
use TCG_Common\Packing\Controllers\CommonPackingController;
$packingController = new CommonPackingController($boxes);
list(
$tooBigOrHeavyItems, $singles, $containerItems, $dimensionBased
) =
$packingController->partitionItems($standardItems);
$singleParcels = $packingController->packSingleItems($singles);
$parcels = array_merge($parcels, $packingController->packTooBigOrHeavyItems($tooBigOrHeavyItems));
[$packedContainers, $fittingItems] = $packingController->packContainerItems($containerItems, $dimensionBased);
$dimensionBased = array_merge($fittingItems, $dimensionBased);
$parcels = array_merge($parcels, $packingController->packDimensionedItems($dimensionBased));