mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-13 23:48:55 +01:00
15 lines
310 B
Ruby
15 lines
310 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Provides methods for update total of cart
|
|
class Cart::UpdateTotalService
|
|
def call(order)
|
|
total = 0
|
|
order.order_items.each do |item|
|
|
total += (item.amount * item.quantity) unless item.is_offered
|
|
end
|
|
order.total = total
|
|
order.save
|
|
order
|
|
end
|
|
end
|