Merge pull request #8144 from meronokbay/6942-fix-payment-method-fee-bug

6942 fix payment method fee bug
This commit is contained in:
Andy Brett
2021-09-09 09:28:40 -07:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ module Spree
before_action :load_data
before_action :validate_payment_method_provider, only: [:create]
before_action :load_hubs, only: [:new, :edit, :update]
before_action :validate_calculator_preferred_amount, only: [:update]
respond_to :html
@@ -173,6 +174,16 @@ module Spree
params_for_update
end
end
def validate_calculator_preferred_amount
preferred_amount = params.dig(:payment_method_check, :calculator_attributes,
:preferred_amount)
return if preferred_amount.nil? || Float(preferred_amount,
exception: false)
flash[:error] = I18n.t(:calculator_preferred_amount_error)
redirect_to spree.edit_admin_payment_method_path(@payment_method)
end
end
end
end

View File

@@ -2321,6 +2321,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
calculator_values: "Calculator values"
calculator_settings_warning: "If you are changing the calculator type, you must save first before you can edit the calculator settings"
calculator_preferred_unit_error: "must be kg or lb"
calculator_preferred_amount_error: "Invalid input. Please use only numbers. For example: 10, 5.5, -20"
flat_percent_per_item: "Flat Percent (per item)"
flat_rate_per_item: "Flat Rate (per item)"
flat_rate_per_order: "Flat Rate (per order)"