Extract before_payment_state? method

This commit is contained in:
Matt-Yorkley
2023-06-13 18:16:09 +01:00
parent 13a22c56f4
commit a0f23fc510
2 changed files with 7 additions and 3 deletions

View File

@@ -316,7 +316,7 @@ module Spree
# Creates new tax charges if there are any applicable rates. If prices already
# include taxes then price adjustments are created instead.
def create_tax_charge!
return if state.in?(["cart", "address", "delivery"])
return if before_payment_state?
clear_legacy_taxes!
@@ -574,6 +574,10 @@ module Spree
end
end
def before_payment_state?
state.in?(["cart", "address", "delivery"])
end
private
def deliver_order_confirmation_email

View File

@@ -24,13 +24,13 @@ class OrderWorkflow
end
def advance_to_payment
return unless order.state.in? ["cart", "address", "delivery"]
return unless order.before_payment_state?
advance_to_state("payment", advance_order_options)
end
def advance_checkout(options = {})
advance_to = order.state.in?(["cart", "address", "delivery"]) ? "payment" : "confirmation"
advance_to = order.before_payment_state? ? "payment" : "confirmation"
advance_to_state(advance_to, advance_order_options.merge(options))
end