Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I ran into an issue where I couldn't activate the plugin in the Shipping Method form.
The following error would be logged, and the plugin form would not load:
Ein AJAX-HTTP-Error occured.
HTTP-Code: 200
Path: /admin/commerce/config/shipping-methods/add?ajax_form=1
Status: OK
Response: TypeError: Return value of Drupal\commerce_shipping\ShippingService::getLabel() must be of the type string, null returned in Drupal\commerce_shipping\ShippingService->getLabel() (line 54 of /Users/xx/xx/xx/xx/modules/contrib/commerce_shipping/src/ShippingService.php)."
I compared the FlatRate class of the Commerce_Shipping plugin to the ShippingByWeight class and noticed that the 'rate_label' in defaultConfiguration() was set to NULL instead of an empty string as in the FlatRate class.
Changing the default to an empty string fixed the error response.
Attached is the Patch in question.
Cheers!
Comment | File | Size | Author |
---|---|---|---|
defaultConfigurationDefaultLabel.patch | 631 bytes | motioneer |
Comments
Comment #2
ysamoylenko CreditAttribution: ysamoylenko at EPAM Systems commentedHello @motioneer,
The issue is already fixed by patch #3 from the page #3109850: Update for Shipping 2.x-dev (post-beta8).
Thank you for the report.
Comment #3
ysamoylenko CreditAttribution: ysamoylenko at EPAM Systems commented