You can register additional shipping providers to post to by registering your class. Then, you'll need to create your provider class to implement the ProviderInterface.
If you're not confident in PHP development, but still looking for provider support, contact us and we'd love to add your provider to Postie.
// smart enough to know what your Commerce settings are, and converts them for you.
This defines the the name of your shipping provider.
Here you need to define the path and filename to a template file which contains further settings description. If you don't want to provide a description then just create an empty file. You have to place it within the template folder of your plugin. This file is where you'll place fields to enter in API settings.
This function should return an array of the provided services as a key-value pair.
key - defines the handle of the service. Should be unique. Best practice is to prepend your plugin handle seperated by a underline.
value - defines the name of the service. It should be self explaining to avoid confusion on customer side.
The fetchShippingRates method is the main function in your class. Its where all the magic happens.
order - this parameter contains the Order with all relevant order details as address, line items, total dimensions and so on. You will need this information to create the API call.
For error catching we scaffolded a try-catch block. Caught errors will be written in the Postie log file. If you want to write errors into your own log file simply replace this log call with your own plugin name.
As each provider requires dimensions and weight values in different units, it can be annoying to cater for this. In fact, you also need to cater for what units your Commerce shop is setup with. Fortuntely, you can use the getDimensions() function to provide you with the correct values for the units you require. Pass it the $order variable, the short-hand unit for weight, and the short-hand unit for dimensions that you require. Postie will take care of all the converting for you!