Streamlined the packaging stuff with some reasonable assumed defaults for now
This commit is contained in:
parent
ad3c950d6d
commit
14c35aa03f
@ -2,52 +2,10 @@
|
||||
|
||||
class Package
|
||||
{
|
||||
const FEDEX_YOUR_PACKAGING = 'YOUR_PACKAGING';
|
||||
const USPS_CONTAINER_RECTANGULAR = 'RECTANGULAR';
|
||||
const USPS_SIZE_LARGE = 'LARGE';
|
||||
|
||||
protected $weight;
|
||||
protected $width;
|
||||
protected $length;
|
||||
protected $height;
|
||||
protected $packaging;
|
||||
protected $size_classification;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSizeClassification()
|
||||
{
|
||||
return $this->size_classification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $size_classification
|
||||
* @return $this
|
||||
*/
|
||||
public function setSizeClassification($size_classification)
|
||||
{
|
||||
$this->size_classification = $size_classification;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPackaging()
|
||||
{
|
||||
return $this->packaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $packaging
|
||||
* @return $this
|
||||
*/
|
||||
public function setPackaging($packaging)
|
||||
{
|
||||
$this->packaging = $packaging;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
|
@ -101,14 +101,35 @@ class Rate extends RateAdapter
|
||||
foreach ($this->shipment->getPackages() as $p) {
|
||||
$sequence_number++;
|
||||
|
||||
/**
|
||||
* RateV4Request / Package / Size
|
||||
required once
|
||||
Defined as follows:
|
||||
|
||||
REGULAR: Package dimensions are 12’’ or less;
|
||||
LARGE: Any package dimension is larger than 12’’.
|
||||
|
||||
For example: <Size>REGULAR</Size>
|
||||
string
|
||||
whiteSpace=collapse
|
||||
enumeration=LARGE
|
||||
enumeration=REGULAR
|
||||
|
||||
*/
|
||||
if ($p->getWidth() > 12 or $p->getLength() > 12 or $p->getHeight() > 12) {
|
||||
$size = 'LARGE';
|
||||
} else {
|
||||
$size = 'REGULAR';
|
||||
}
|
||||
|
||||
$packages .= '<Package ID="' . $sequence_number .'">
|
||||
<Service>ALL</Service>
|
||||
<ZipOrigination>' . $this->shipment->getFromPostalCode() . '</ZipOrigination>
|
||||
<ZipDestination>' . $this->shipment->getToPostalCode() . '</ZipDestination>
|
||||
<Pounds>' . $p->getWeight() . '</Pounds>
|
||||
<Ounces>0</Ounces>
|
||||
<Container>' . $p->getPackaging() . '</Container>
|
||||
<Size>' . $p->getSizeClassification() . '</Size>
|
||||
<Container>RECTANGULAR</Container>
|
||||
<Size>' . $size . '</Size>
|
||||
<Width>' . $p->getWidth() . '</Width>
|
||||
<Length>' . $p->getLength() . '</Length>
|
||||
<Height>' . $p->getHeight() . '</Height>
|
||||
|
@ -61,9 +61,7 @@ class ShipTest extends PHPUnit_Framework_TestCase
|
||||
$p->setWeight(3)
|
||||
->setWidth(9)
|
||||
->setLength(9)
|
||||
->setHeight(9)
|
||||
->setPackaging(Package::USPS_CONTAINER_RECTANGULAR)
|
||||
->setSizeClassification(Package::USPS_SIZE_LARGE);
|
||||
->setHeight(9);
|
||||
|
||||
$s->addPackage($p);
|
||||
|
||||
@ -107,11 +105,6 @@ class ShipTest extends PHPUnit_Framework_TestCase
|
||||
$ship = Ship::factory($this->shipping_options);
|
||||
$approved_codes = $ship->get_approved_codes('fedex');
|
||||
|
||||
$ps = $this->shipment->getPackages();
|
||||
foreach ($ps as $p) {
|
||||
$p->setPackaging(Package::FEDEX_YOUR_PACKAGING);
|
||||
}
|
||||
|
||||
return [
|
||||
'prod' => FALSE,
|
||||
'key' => 'XXXX',
|
||||
|
Loading…
x
Reference in New Issue
Block a user