You can register your own Provider to add support for other carriers, or even extend an existing Provider.
Postie uses the Shippy (opens new window) package for all provider logic. As such, you should first become familiar with how creating a custom carrier in Shippy works. Then, you can add support for your Shippy Carrier as a Postie Provider.
For our example, let's use the fictional Wakanda Post
carrier for the rest of this guide. This provider needs an apiKey
setting to authenticate with the API. Your provider may have different requirements.
Let's start by creating a very simple Shippy Carrier class. Again, refer to the Shippy docs (opens new window) for more.
Create the following class in modules/WakandaPostCarrier.php
.
Here, we've created a Shippy Carrier class that uses their (fictional) API endpoint to fetch rates. The logic of this class is up to you to implement the action fetching of the rates.
Next, connect the Shippy Carrier to a new Postie Provider as modules/WakandaPost.php
You can see the bulk of the logic for fetching rates resides in the WakandaPostCarrier
class, and the WakandaPost
class acts as the connector between Postie and Shippy.