meanbee / royalmail-php-library
PHP library for Royal Mail shipping shipping methods
Installs: 2 728
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 8
Forks: 0
Open Issues: 0
Requires (Dev)
- fabpot/php-cs-fixer: ^1.11
- phpro/grumphp: ^0.9.0
- phpunit/phpunit: 4.*
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^2.5
- dev-master
- 2.1.0
- v2.0.1
- v2.0.0
- 1.0.3
- 1.0.1
- 1.0.0
- dev-develop
- dev-51-merge-csv-3-and-5
- dev-separating-concerns
- dev-50-add-group-to-methods
- dev-42-assign-to-type
- dev-27-getallmethods-function
- dev-23-restrict-privacy-of-variables
- dev-22-rename-calculatemethod-class
- dev-38-grumphp
- dev-24-calculate-method-constructor
- dev-25-reduce-new-data-instantiations
This package is not auto-updated.
Last update: 2023-08-05 12:08:57 UTC
README
This repository contains the source code for the Meanbee Royal Mail PHP Library. It takes the country code, package value, and package weight and then outputs an array of objects containing the available shipping methods.
Using the Library
To use the library, call the getMethods method with your country code (in the ISO 3166 format), package value, and package weight.
Example Usage
$calculateMethodClass = new CalculateMethodClass(); $calculateMethodClass->getMethods('GB', 20, 0.050);
This will return an array of objects where each object contains the shipping method name, minimum weight, maximum weight, price of the method, maximum insurance value, and proper name of the shipping method.
Unit Testing
This program is automatically unit tested with phpunit and travis.
CSV data format
This library uses six CSV files to determine which shipping methods are available:
-
- Country code
- World zone. Each country, defined by its country code can be in more then one zone. The code "GB" for Great Britain is in the EU and the GB World zone. There are four world zones:
- WORLD_ZONE_GB
- WORLD_ZONE_EU
- WORLD_ZONE_ONE
- WORLD_ZONE_TWO
-
- World zone
- Shipping zone.
Each shipping method's name starts with the world zone it links to as prices differ between zones.
-
- Delivery method
- Minimum price of method
- Maximum price available to the method (the maximum price of shipping cart this method applies to)
- Max insurance available on method
- Human-friendly method name
- Delivery group
-
- Method name
- Minimum weight
- Maximum weight
- Price of method
- Max insurance value
- In the case of small or medium parcel up to 2kg in weight "SMALL" or "MEDIUM" else blank
Method names are constructed in the WORLDZONE_NAME_WITH_UNDERSCORES format with a separate method being added for each separate foramt. Examples of these can be seen in multiple of the csvs. In the case of extra insurance available on the item, another method must be created. An example can be seen in the 3_deliveryMethodMeta.csv.