mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Don't need to show any ship_address errors if no ship selected nor
if the ship_address is the same than the billing one
This commit is contained in:
@@ -59,12 +59,17 @@ class SplitCheckoutController < ::BaseController
|
||||
|
||||
def order_error_messages
|
||||
# Remove ship_address.* errors if no shipping method is not selected
|
||||
remove_ship_address_errors if @order.errors[:shipping_method].present?
|
||||
remove_ship_address_errors if no_ship_address_needed?
|
||||
|
||||
# Reorder errors to make sure the most important ones are shown first
|
||||
# and finally, return the error messages to sentence
|
||||
reorder_errors.map(&:full_message).to_sentence
|
||||
end
|
||||
|
||||
def no_ship_address_needed?
|
||||
@order.errors[:shipping_method].present? || params[:ship_address_same_as_billing] == "1"
|
||||
end
|
||||
|
||||
def remove_ship_address_errors
|
||||
@order.errors.delete("ship_address.firstname")
|
||||
@order.errors.delete("ship_address.address1")
|
||||
|
||||
Reference in New Issue
Block a user