Skip to content

Commit

Permalink
Dimensions Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Moustafa22 committed Sep 14, 2020
1 parent f30c31a commit 6bea25b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,19 @@ composer require octw/aramex

``` php
[
'payment_type':'', // default value in config file
'product_group':'', // default value in config file
'product_type':'', // default value in config file
'weight':'Double', // IN KG (Kilograms)
'number_of_pieces':'Integer|Required'
'payment_type' => '', // default value in config file
'product_group' => '', // default value in config file
'product_type' => '', // default value in config file
'weight' => 5.2, // IN KG (Kilograms)
'number_of_pieces' => 'Integer|Required',
'height' => 5, // Dimensions in CM (optional)
'width' => 3, // Dimensions in CM (optional)
'length' => 2 // Dimensions in CM (optional)
]
```

The `$currency` is a string (3 Chars) for prefered currency calculations like `USD`,`AED`,`EUR`,`KWD` and so on. <br />

Note that in case you want pass the dimensions, it will not take the parameters unless you pass all the `height`, `width`, `length`. <br />

Sample Code

Expand All @@ -328,20 +331,24 @@ composer require octw/aramex
'line_1' => 'Test String',
'city' => 'Dubai',
'country_code' => 'AE'

];

$shipmentDetails = [
'weight' => 5, // KG
'number_of_pieces' => 2,
'payment_type' => 'P', // if u don't pass it, it will take the config default value
'product_group' => 'EXP', // if u don't pass it, it will take the config default value
'product_type' => 'PPX', // if u don't pass it, it will take the config default value
'height' => 5.5, // CM
'width' => 3, // CM
'length' => 2.3 // CM
];

$shipmentDetails = [
'weight' => 5, // KG
'number_of_pieces' => 2,
]
'number_of_pieces' => 2,
];

$currency = 'USD';
$data = Aramex::calculateRate($originAddress, $destinationAddress , $shipmentDetails , 'USD');

Expand Down
9 changes: 9 additions & 0 deletions src/Helpers/AramexHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ public static function extractCalculateRateShipmentDetails($param)
$details->ActualWeight->Unit = 'KG';
$details->NumberOfPieces = $param['number_of_pieces'];

if (!empty($param['length']) && !empty($param['width']) && !empty($param['height']) )
{
$details->Dimensions = new \stdClass;
$details->Dimensions->Length = floatval($param['length']);
$details->Dimensions->Width = floatval($param['width']);
$details->Dimensions->Height = floatval($param['height']);
$details->Dimensions->Unit = 'CM';
}

return $details;
}

Expand Down

0 comments on commit 6bea25b

Please sign in to comment.