ShippingContext containing the full order details and returns a structured array of labelled rate options. The registration flow is identical to display plugins, so if you’ve already built one of those, building a shipping plugin will feel immediately familiar.
The ShippingPlugin Interface
Every shipping plugin must implement the following contract:The ShippingContext Object
TheShippingContext passed to calculateRates() carries everything you need to compute a rate:
Access these properties inside your plugin to call a carrier API or apply your own rate table logic.
Expected Return Format
calculateRates() must return a flat array of associative rate options. Each option requires a label and a numeric rate:
label, and the rate is added to the order total.
Return an empty array
[] when no rates are available for the given context — for example, when the destination country is outside your coverage area. Site Store Pro will suppress the plugin’s options at checkout rather than showing a zero-rate entry.Complete Example: Flat-Rate Shipping Plugin
Here is a minimal but fully functional shipping plugin that demonstrates reading a plugin setting and returning tiered flat rates:Registering a Shipping Plugin
You can register a shipping plugin as a built-in class or as a drop-in directory — the process mirrors display plugins exactly.- Built-in (PluginServiceProvider)
- Drop-in (/plugins/ directory)
Place your class in Then add the database record and any option fields via the
app/Plugins/Shipping/ and register it in app/Providers/PluginServiceProvider.php:PluginSeeder and reseed:Plugin Model Helpers
ThePlugin model passed to calculateRates() provides the same three convenience methods available to display plugins. Their formal signatures are: