mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
27 lines
755 B
Ruby
27 lines
755 B
Ruby
module Spree
|
|
module OrdersHelper
|
|
def cart_is_empty
|
|
order = current_order(false)
|
|
order.nil? || order.line_items.empty?
|
|
end
|
|
|
|
def order_distribution_subtotal(order, options={})
|
|
options.reverse_merge! :format_as_currency => true
|
|
amount = order.adjustments.enterprise_fee.sum &:amount
|
|
options.delete(:format_as_currency) ? spree_number_to_currency(amount) : amount
|
|
end
|
|
|
|
def alternative_available_distributors(order)
|
|
DistributionChangeValidator.new(order).available_distributors(Enterprise.all) - [order.distributor]
|
|
end
|
|
|
|
def last_completed_order
|
|
spree_current_user.orders.complete.last
|
|
end
|
|
|
|
def cart_count
|
|
current_order.andand.line_items.andand.count || 0
|
|
end
|
|
end
|
|
end
|