mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
By default, we reject all adjustements with amount equal to 0
This commit is contained in:
@@ -11,6 +11,7 @@ module CheckoutHelper
|
||||
|
||||
def checkout_adjustments_for(order, opts = {})
|
||||
exclude = opts[:exclude] || {}
|
||||
reject_zero_amount = opts.fetch(:reject_zero_amount, true)
|
||||
|
||||
adjustments = order.all_adjustments.eligible.to_a
|
||||
|
||||
@@ -32,6 +33,10 @@ module CheckoutHelper
|
||||
}
|
||||
end
|
||||
|
||||
if reject_zero_amount
|
||||
adjustments.reject! { |a| a.amount == 0 }
|
||||
end
|
||||
|
||||
adjustments
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
= t :checkout_cart_total
|
||||
%td.cart-total.text-right= display_checkout_subtotal(@order)
|
||||
|
||||
- checkout_adjustments_for(current_order, exclude: [:shipping, :payment, :line_item]).reject{ |a| a.amount == 0 }.each do |adjustment|
|
||||
- checkout_adjustments_for(current_order, exclude: [:shipping, :payment, :line_item]).each do |adjustment|
|
||||
%tr.adjustment
|
||||
%th= adjustment.label
|
||||
%td.text-right= adjustment.display_amount.to_html
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
.summary-right-line-label= t :order_produce
|
||||
.summary-right-line-value= display_checkout_subtotal(@order)
|
||||
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
.summary-right-line
|
||||
.summary-right-line-label= adjustment.label
|
||||
.summary-right-line-value= adjustment.display_amount.to_html
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
%td{:align => "right"}
|
||||
= item.display_amount_with_adjustments
|
||||
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
- taxable = adjustment.adjustable_type == "Spree::Shipment" ? adjustment.adjustable : adjustment
|
||||
%tr
|
||||
%td
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
%td{:align => "right"}
|
||||
= display_line_item_tax_rates(item)
|
||||
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
%tr
|
||||
%td
|
||||
%strong= "#{raw(adjustment.label)}"
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
j(line_item.display_amount_with_adjustments.format(symbol: false, with_currency: false))] }
|
||||
.join('" + \'\x0A\' + "')}",
|
||||
'\x0A',
|
||||
"#{checkout_adjustments_for(@order, exclude: [:line_item])
|
||||
"#{checkout_adjustments_for(@order, exclude: [:line_item], reject_zero_amount: false)
|
||||
.reject{ |a| a.amount == 0 }
|
||||
.reverse.map { |adjustment| '%5s %-27.27s%8.8s' %
|
||||
["",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
= t :email_order_summary_subtotal
|
||||
%td{align: "right"}
|
||||
= display_checkout_subtotal(@order)
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
%tr
|
||||
%td{align: "right", colspan: "3"}
|
||||
= "#{raw(adjustment.label)}:"
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
%span.order-total.item-total= display_checkout_subtotal(@order)
|
||||
%td
|
||||
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
%tr.order-adjustment
|
||||
%td.text-right{:colspan => "3"}
|
||||
= adjustment.label
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
%span= display_checkout_subtotal(order)
|
||||
|
||||
#order-charges{"data-hook" => "order_details_adjustments"}
|
||||
- checkout_adjustments_for(order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
|
||||
- checkout_adjustments_for(order, exclude: [:line_item]).reverse_each do |adjustment|
|
||||
%tr.total
|
||||
%td.text-right{:colspan => "3"}
|
||||
%strong
|
||||
|
||||
Reference in New Issue
Block a user