Sha256: f4fc0f43f75ea900ea3769cc43889896a72d48a13894580cfbf705171791bff1
Contents?: true
Size: 674 Bytes
Versions: 30
Compression:
Stored size: 674 Bytes
Contents
module Spree module Cart class ChangeCurrency prepend Spree::ServiceModule::Base def call(order:, new_currency:) return failure('Currency not supported') unless supported_currency?(order, new_currency) result = order.update!(currency: new_currency) rescue false if result success(order) else failure('Failed to update order') end end private def supported_currency?(order, currency) store = order.store supported_currencies = store.supported_currencies_list supported_currencies.map(&:iso_code).include?(currency.upcase) end end end end
Version data entries
30 entries across 30 versions & 1 rubygems