No pain ... assuming that your client wants to use the following "rules":
1) Z < X < Y and are all specified in ounces
2) If weight <= Z, use flat rate envelope
3) If weight > Z and <= X use sm flat rate box
4) If weight > X and <= Y use md flat rate box
5) Otherwise (weight > Y) use lg flat rate box
Code:
//PRIORITY MAIL OPTIONS
if ($key == 'PRIORITY'){
$weight = $this->pounds*16 + $this->ounces;
if ($weight <= Z) {
$this->container = "Flat Rate Envelope";
} elseif ($weight <= X) {
$this->container = 'Sm Flat Rate Box';
} elseif ($weight > Y) {
$this->container = 'Lg Flat Rate Box';
} else {
$this->container = 'Md Flat Rate Box';
}
}
Bookmarks