13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/helpers/my_quotes_helper.rb', line 13
def display_discounted_shipping_price(quote)
shipping_cost = quote.line_items.shipping_only.to_a.sum(&:price_total)
discounted_shipping_cost = quote.discounted_shipping_total
currency_symbol = begin
quote.currency_symbol
rescue StandardError
Money::Currency.new('USD').symbol
end
if shipping_cost == discounted_shipping_cost
number_to_currency(shipping_cost, unit: currency_symbol)
elsif discounted_shipping_cost.zero?
tag.del(number_to_currency(shipping_cost, unit: currency_symbol), class: 'text-muted small me-1') +
tag.span('FREE', class: 'text-success fw-bold')
else
tag.del(number_to_currency(shipping_cost, unit: currency_symbol), class: 'text-muted small me-1') +
tag.span(number_to_currency(discounted_shipping_cost, unit: currency_symbol), class: 'text-danger fw-bold')
end
end
|