Magento 2
Developer Guide
Overview
The Nysa_ShipRateAPIextension adds ShipRateAPI as a native shipping carrier in Magento 2. At checkout, Magento calls the extension's collectRates()method, which builds a payload from the cart and destination, POSTs it to the ShipRateAPI API server-side, and maps the response back to Magento rate objects — all without the API key ever reaching the browser.
- Magento 2.4+ / Adobe Commerce 2.4+
- PHP 8.1 or higher
- Composer 2
Installation
Install via Composer from your Magento root:
composer require nysa/shiprate
bin/magento module:enable Nysa_ShipRateAPI
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:cleanThe setup:upgrade step runs the data patch that creates the shiprate_tags product attribute. If you are deploying to a production environment, run setup:static-content:deploy afterwards.
Admin configuration
Navigate to Stores → Configuration → Sales → Shipping Methods → ShipRateAPI Live Rates.
| Field | Description |
|---|---|
| Enabled | Set to Yes to activate the carrier at checkout |
| Title | Label displayed to customers in the checkout shipping group (default: ShipRateAPI Live Rates) |
| API Endpoint URL | The ShipRateAPI quotes endpoint — e.g. https://api.shiprateapi.com/api/v1/quotes. Stored in full so the version path can be updated without a code release. The extension sends X-Platform: magento2 automatically. |
| API Key | Your ShipRateAPI API key. Stored encrypted in core_config_data. |
| Sort Order | Display order relative to other carriers at checkout |
| Attribute Tag Mapping | Rule table mapping product attribute values to ShipRateAPI tags (see below) |
Product tagging
Tags are sent per line item in the API payload and can be used in the ShipRateAPI admin to control carrier routing (e.g. only show cold-chain carriers for products tagged cold-storage). There are two ways to assign tags:
Layer 1 — Direct tags via product attribute
The extension installs a shiprate_tags varchar attribute on the product entity. To tag a product, edit it in Catalog → Products, open the ShipRateAPI tab, and enter a comma-separated list:
cold-storage, fragile, medicineLayer 2 — Attribute mapping rules
The Attribute Tag Mapping table in the carrier config lets you derive tags from any existing product attribute without editing each product individually. Each row defines a rule:
| Column | Description |
|---|---|
| Product Attribute Code | Any EAV product attribute code (e.g. hazmat_class). Validated against the catalog on save. |
| Operator | equals (=), not equals (!=), or contains |
| Attribute Value | The value to compare the product attribute against |
| ShipRateAPI Tag | The tag to append when the rule matches |
Tags from both layers are merged and deduplicated before being sent. See Tags & Routing for how tags affect carrier selection.