Problem/Motivation
Some shipping method plugins provide lists of services with numerical ids
commerce_ups example:
/**
* Provides the UPS shipping method.
*
* @CommerceShippingMethod(
* id = "ups",
* label = @Translation("UPS"),
* services = {
* "01" = @translation("UPS Next Day Air"),
* "02" = @translation("UPS Second Day Air"),
* "03" = @translation("UPS Ground"),
* "07" = @translation("UPS Worldwide Express"),
* "08" = @translation("UPS Worldwide Expedited"),
* "11" = @translation("UPS Standard"),
* "12" = @translation("UPS Three-Day Select"),
* "13" = @translation("UPS Next Day Air Saver"),
* "14" = @translation("UPS Next Day Air Early AM"),
* "54" = @translation("UPS Worldwide Express Plus"),
* "59" = @translation("UPS Second Day Air AM"),
* "65" = @translation("UPS Saver"),
* "70" = @translation("UPS Access Point Economy"),
* }
* )
*/
In src/Plugin/Commerce/ShippingMethod/ShippingMethodBase.php a list of ShippingServices is created when the class is invoked.
Some of the above ids are set as strings eg: "01" while others are integers eg: "65".
src/ShippingService.php makes it clear the id is a string, not an integer
This issue is probably related to this
#3179322: Duplicate services in shipping method configuration β
Proposed resolution
When creating the list of services ensure the type for $id is set to string
foreach ($this->pluginDefinition['services'] as $id => $label) {
$this->services[$id] = new ShippingService((string) $id, (string) $label);
}