Working With Addons¶
By default, USPS will return all available addons with each rate to show the user which addons are available. RocketShipIt comes with a few helpers to make selecting addons easier.
-
$rate->filterAddons($rate, array $addonsToFilter)
Filters out only selected addons
Parameters: - $rate (object) – Rate object from Stamps.com
- $addonsToFilter (array) – List of addons
Returns: Original rate object with addons removed
-
$rate->isAddonsCompatible($rate, array $addons)
Checks if selected addons meet USPS requirements, for example US-A-DC and US-A-SC cannot be used together.
Parameters: - $rate (object) – Rate object from Stamps.com
- $addons (array) – List of addons
Returns: bool
Example:
<?php
$shipment = new \RocketShipIt\Shipment('STAMPS');
$shipment->setParameter('toCompany', 'RocketShipIt');
$shipment->setParameter('toName', 'John Doe');
$shipment->setParameter('toAddr1', '111 W Legion');
$shipment->setParameter('toCity', 'Whitehall');
$shipment->setParameter('toState', 'MT');
$shipment->setParameter('toCode', '59759');
$shipment->setParameter('referenceValue', '123adsf');
$rate = new \RocketShipIt\Rate('STAMPS');
$rate->setParameter('toCode', '59759');
$rate->setParameter('weight', '5');
$rate->setParameter('service', 'US-MM');
$rate->setParameter('packagingType', 'Package');
$package = $rate->getRate();
if (!$rate->inherited->isAddonsCompatible($package, array('US-A-DC')) {
// Handle cases where addons are not compatible
}
// Remove all addons except delivery confirmation
$rate->inherited->filterAddons($package, array('US-A-DC'));
$shipment->setParameter('toCode', $package->ToZIPCode);
$shipment->addPackageToShipment($package);
$response = $shipment->submitShipment();
USPS Addon Services¶
Value | Description |
---|---|
SC-A-HP | Stamps.com Hidden Postage |
SC-A-INS | Stamps.com Insurance |
SC-A-INSRM | Stamps.com Insurance for Registered Mail |
US-A-CM | USPS Certified Mail |
US-A-COD | USPS Collect on Delivery |
US-A-COM | USPS Certificate of Mailing. Currently unsupported. |
US-A-DC | Include Delivery Confirmation service. Charges may apply. |
US-A-ESH | Guaranteed Express Mail delivery on a Sunday or holiday, incurring an additional fee. |
US-A-INS | USPS Insurance. Currently unsupported. |
US-A-NDW | Instruct the USPS not to attempt Express Mail delivery on a Saturday (formerly weekend) when a business may be closed. |
US-A-SC | Include Signature Confirmation service. |
US-A-WDS | Express Mail item can be delivered without obtaining a signature. |
US-A-NDW | Express Mail item cannot be delivered on Saturdays. |
US-A-ESH | Express Mail item will be delivered on Sunday or Holiday. |
US-A-RRE | Electronic Return Receipt (ERR) is a USPS Extra Service that includes Signature proof of delivery. |