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
|
class Package
|
||||||
{
|
{
|
||||||
const FEDEX_YOUR_PACKAGING = 'YOUR_PACKAGING';
|
|
||||||
const USPS_CONTAINER_RECTANGULAR = 'RECTANGULAR';
|
|
||||||
const USPS_SIZE_LARGE = 'LARGE';
|
|
||||||
|
|
||||||
protected $weight;
|
protected $weight;
|
||||||
protected $width;
|
protected $width;
|
||||||
protected $length;
|
protected $length;
|
||||||
protected $height;
|
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
|
* @return mixed
|
||||||
|
@ -101,14 +101,35 @@ class Rate extends RateAdapter
|
|||||||
foreach ($this->shipment->getPackages() as $p) {
|
foreach ($this->shipment->getPackages() as $p) {
|
||||||
$sequence_number++;
|
$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 .'">
|
$packages .= '<Package ID="' . $sequence_number .'">
|
||||||
<Service>ALL</Service>
|
<Service>ALL</Service>
|
||||||
<ZipOrigination>' . $this->shipment->getFromPostalCode() . '</ZipOrigination>
|
<ZipOrigination>' . $this->shipment->getFromPostalCode() . '</ZipOrigination>
|
||||||
<ZipDestination>' . $this->shipment->getToPostalCode() . '</ZipDestination>
|
<ZipDestination>' . $this->shipment->getToPostalCode() . '</ZipDestination>
|
||||||
<Pounds>' . $p->getWeight() . '</Pounds>
|
<Pounds>' . $p->getWeight() . '</Pounds>
|
||||||
<Ounces>0</Ounces>
|
<Ounces>0</Ounces>
|
||||||
<Container>' . $p->getPackaging() . '</Container>
|
<Container>RECTANGULAR</Container>
|
||||||
<Size>' . $p->getSizeClassification() . '</Size>
|
<Size>' . $size . '</Size>
|
||||||
<Width>' . $p->getWidth() . '</Width>
|
<Width>' . $p->getWidth() . '</Width>
|
||||||
<Length>' . $p->getLength() . '</Length>
|
<Length>' . $p->getLength() . '</Length>
|
||||||
<Height>' . $p->getHeight() . '</Height>
|
<Height>' . $p->getHeight() . '</Height>
|
||||||
|
@ -61,9 +61,7 @@ class ShipTest extends PHPUnit_Framework_TestCase
|
|||||||
$p->setWeight(3)
|
$p->setWeight(3)
|
||||||
->setWidth(9)
|
->setWidth(9)
|
||||||
->setLength(9)
|
->setLength(9)
|
||||||
->setHeight(9)
|
->setHeight(9);
|
||||||
->setPackaging(Package::USPS_CONTAINER_RECTANGULAR)
|
|
||||||
->setSizeClassification(Package::USPS_SIZE_LARGE);
|
|
||||||
|
|
||||||
$s->addPackage($p);
|
$s->addPackage($p);
|
||||||
|
|
||||||
@ -107,11 +105,6 @@ class ShipTest extends PHPUnit_Framework_TestCase
|
|||||||
$ship = Ship::factory($this->shipping_options);
|
$ship = Ship::factory($this->shipping_options);
|
||||||
$approved_codes = $ship->get_approved_codes('fedex');
|
$approved_codes = $ship->get_approved_codes('fedex');
|
||||||
|
|
||||||
$ps = $this->shipment->getPackages();
|
|
||||||
foreach ($ps as $p) {
|
|
||||||
$p->setPackaging(Package::FEDEX_YOUR_PACKAGING);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'prod' => FALSE,
|
'prod' => FALSE,
|
||||||
'key' => 'XXXX',
|
'key' => 'XXXX',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user