You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We noticed that after shipping an order (from the admin), the shipment state would not change to shipped.
After digging around, it seems this is being caused by the way the order_recalculated event is being handled
The Solidus OrderUpdater class has this method, which updates the shipping state and other things:
def update
order.transaction do
update_item_count
update_shipment_amounts
update_totals
if order.completed?
update_payment_state
update_shipments
update_shipment_state
end
Spree::Event.fire 'order_recalculated', order: order
persist_totals
end
end
When Spree::Event.fire 'order_recalculated', order: order is called, the KlarnaSubsciber calls order.update_klarna_shipments:
def update_klarna_shipments
return unless shipment_state_changed? && shipment_state == "shipped"
captured_klarna_payments.each do |payment|
payment.payment_method.gateway.shipping_info(
payment.source.order_id,
payment.source.capture_id,
shipping_info: to_klarna(
payment.payment_method.preferred_country
).shipping_info
)
end
end
and the to_klarna method reloads the order:
def to_klarna(country = :us)
SolidusKlarnaPayments::OrderSerializer.new(reload, country)
end
... the order reload in the method above causes the OrderUpdater to no longer see changed values, including the shipment_state.
Maybe this should be a Solidus issue, but figured I would start here since it is only happening with Klarna orders.
The text was updated successfully, but these errors were encountered:
We noticed that after shipping an order (from the admin), the shipment state would not change to
shipped
.After digging around, it seems this is being caused by the way the
order_recalculated
event is being handledThe Solidus OrderUpdater class has this method, which updates the shipping state and other things:
When
Spree::Event.fire 'order_recalculated', order: order
is called, the KlarnaSubsciber callsorder.update_klarna_shipments
:and the
to_klarna
method reloads the order:... the order reload in the method above causes the
OrderUpdater
to no longer see changed values, including theshipment_state
.Maybe this should be a Solidus issue, but figured I would start here since it is only happening with Klarna orders.
The text was updated successfully, but these errors were encountered: