Skip to content

Commit bbe7065

Browse files
forkatabenjaminwilKendra RigaNoah-Silverajarednorman
committed
Allow the order updater to handle non-persisted line items
In an associated change we made the `CreateDiscountedItem` benefit create in-memory line items. That causes an issue during the recalculation of the item totals. Co-authored-by: benjamin wil <benjamin@super.gd> Co-authored-by: Kendra Riga <kendra@super.gd> Co-authored-by: Noah Silvera <noah@super.gd> Co-authored-by: Jared Norman <jared@super.gd>
1 parent cec63a8 commit bbe7065

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

core/app/models/spree/order_updater.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,11 @@ def recalculate_item_totals
232232

233233
next unless item.changed?
234234

235-
item.update_columns(
235+
item.assign_attributes(
236236
promo_total: item.promo_total,
237237
included_tax_total: item.included_tax_total,
238238
additional_tax_total: item.additional_tax_total,
239-
adjustment_total: item.adjustment_total,
240-
updated_at: Time.current,
239+
adjustment_total: item.adjustment_total
241240
)
242241
end
243242
end

legacy_promotions/app/patches/models/solidus_legacy_promotions/spree_order_updater_patch.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ def recalculate_item_totals
3030
reject(&:included?).
3131
sum(&:amount)
3232

33-
if item.changed?
34-
item.update_columns(
35-
promo_total: item.promo_total,
36-
included_tax_total: item.included_tax_total,
37-
additional_tax_total: item.additional_tax_total,
38-
adjustment_total: item.adjustment_total,
39-
updated_at: Time.current,
40-
)
41-
end
33+
next unless item.changed?
34+
35+
item.assign_attributes(
36+
promo_total: item.promo_total,
37+
included_tax_total: item.included_tax_total,
38+
additional_tax_total: item.additional_tax_total,
39+
adjustment_total: item.adjustment_total
40+
)
4241
end
4342
end
4443
Spree::OrderUpdater.prepend self

0 commit comments

Comments
 (0)