Fix error saving data on new Calculator

This commit is contained in:
James Wu
2023-01-26 16:07:26 +09:00
committed by David Cook
parent 41ce4fbc16
commit ae5f2cc19d
2 changed files with 77 additions and 0 deletions

View File

@@ -182,6 +182,11 @@ module Spree
end
end
# Ensure the calculator to be updated is the correct type
if params_for_update["calculator_type"] && params_for_update["calculator_attributes"]
add_type_to_calculator_attributes(params_for_update)
end
params_for_update
end
end
@@ -191,6 +196,10 @@ module Spree
Rails.cache.delete(@payment_method.calculator.preference_cache_key(key))
end
end
def add_type_to_calculator_attributes(hash)
hash["calculator_attributes"]["type"] = hash["calculator_type"]
end
end
end
end