diff --git a/app/controllers/shop/orders_controller.rb b/app/controllers/shop/orders_controller.rb index 11b914eb0..cd81ae104 100644 --- a/app/controllers/shop/orders_controller.rb +++ b/app/controllers/shop/orders_controller.rb @@ -97,6 +97,10 @@ def create current_user.lock! @shop_item.lock! if @shop_item.limited? + # recalc mod prices after lock so theyre fresh + modifiers_total = @modifiers.sum { |m| m.price_for_region(region) } + total_cost = item_total + accessories_total + modifiers_total + if @mission_submission.nil? user_balance = current_user.balance if total_cost > user_balance diff --git a/app/models/shop_order.rb b/app/models/shop_order.rb index b2ba1d4a6..254561fde 100644 --- a/app/models/shop_order.rb +++ b/app/models/shop_order.rb @@ -377,7 +377,9 @@ def check_user_balance return if redeeming_mission_submission.present? return unless frozen_item_price&.positive? && quantity.present? - total_cost_for_validation = frozen_item_price * quantity + # include modifier costs in the balance check + modifier_cost = frozen_modifiers_price || 0 + total_cost_for_validation = (frozen_item_price * quantity) + modifier_cost if user&.balance&.< total_cost_for_validation shortage = total_cost_for_validation - (user.balance || 0) errors.add(:base, "Insufficient balance. You need #{shortage} more tickets.")