Introduce "zero priced order" concept with no required payment

This applies to cases where an order contains items with zero price or where applied vouchers have reduced the order's total to zero.
This commit is contained in:
Matt-Yorkley
2023-06-01 19:09:54 +01:00
parent b175793b91
commit 3d44f4bc98
3 changed files with 17 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ module Spree
go_to_state :delivery
go_to_state :payment, if: ->(order) {
order.update_totals
order.payment_required?
order.payment_required? || order.zero_priced_order?
}
go_to_state :confirmation
go_to_state :complete
@@ -219,6 +219,12 @@ module Spree
total.to_f > 0.0 && !skip_payment_for_subscription?
end
# There are items present in the order, but either the items have zero price,
# or the order's total has been modified (maybe discounted) to zero.
def zero_priced_order?
valid? && line_items.count.positive? && total.zero?
end
# Returns the relevant zone (if any) to be used for taxation purposes.
# Uses default tax zone unless there is a specific match
def tax_zone

View File

@@ -11,11 +11,15 @@
%strong
= order.display_total.to_html
.pad
.text-big
= t :order_payment
%strong= last_payment_method(order)&.name
%p.text-small.text-skinny.pre-line.word-wrap
%em= last_payment_method(order)&.description
- if (order_payment_method = last_payment_method(order))
.text-big
= t :order_payment
%strong= order_payment_method&.name
%p.text-small.text-skinny.pre-line.word-wrap
%em= order_payment_method&.description
- else
.text-big
= t(:no_payment_required)
.order-summary.text-small
%strong

View File

@@ -2120,6 +2120,7 @@ en:
order_not_paid: NOT PAID
order_total: Total order
order_payment: "Paying via:"
no_payment_required: "No payment required"
order_billing_address: Billing address
order_delivery_on: Delivery on
order_delivery_address: Delivery address