From fe10b4cf12d18327cff6d1760e7c3d4fa3dc4390 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 11 Jul 2023 20:00:59 -0600 Subject: [PATCH] Add second example --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 865356a..45b2e29 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,22 @@ $retail_rate = RetailPriceChart::getPrice( true); ``` +More complete example for getting the retail rate from EasyPost, then falling back to this tool if possible: +```php +$retail_rate = $rate->retail_rate ?? ($rate->list_rate ?? $rate->rate); +if ($rate->carrier == "USPS" && ($rate->retail_rate == $rate->rate) && ($rate->service == "Priority" || $rate->service == "GroundAdvantage")) { + // EasyPost not providing retail rate, let's look it up ourselves + if ($shipment->parcel->predefined_package == null) { + try { + $retail_rate = RetailPriceChart::getPrice($shipment->parcel->weight, $shipment->usps_zone, $rate->service, + [$shipment->parcel->length, $shipment->parcel->width, $shipment->parcel->height], true); + } catch (Exception $ex) { + + } + } +} +``` + ## Documentation ```php