Calling getShippingMethod()
on a cart returns nothing for Postie-provided shipping methods
#2279
Labels
getShippingMethod()
on a cart returns nothing for Postie-provided shipping methods
#2279
In Commerce 3.4.x, calling
{{ cart.shippingMethod.name }}
now returnsnull
during checkout, despite having the shipping method applied on the order, which can be seen reflected in the control panel for the active order. This is happening for Postie-provided shipping methods, which are provided on-the-fly.This is due to refactored code for
Order::getShippingMethod()
which callsgetShippingMethodByHandle()
which in turn callsgetAllShippingMethods()
.My first issue is that the docblock for the
getAllShippingMethods()
method states:Which doesn't seem true at all, and even in previous Commerce versions, this has never been the case. Here, it should return both "normal" shipping methods defined by the user in the control panel for Commerce's setting, and any shipping methods provided by plugins or modules. It has only ever done the former?
Secondly, the
Order::getShippingMethod()
has drastically changed from 3.3.5.1commerce/src/elements/Order.php
Lines 2976 to 3012 in 66bb551
Most importantly, the previous function was using
Plugin::getInstance()->getShippingMethods()->getAvailableShippingMethods()
which was returning the correct collection because it actually includes the calls toEVENT_REGISTER_AVAILABLE_SHIPPING_METHODS
which plugins and modules use.So I suppose one of these sides needs fixing. Either the Order
getShippingMethod()
should callgetAvailableShippingMethods()
or thegetAllShippingMethods()
service method needs to include shipping methods provided by the event. Or - something else I'm missing.Also refer to issue verbb/postie#72 which is instance of the issue.
Additional info
The text was updated successfully, but these errors were encountered: