Class: Workarea::Storefront::Checkout::SummaryViewModel

Inherits:
ApplicationViewModel
  • Object
show all
Includes:
OrderPricing
Defined in:
app/view_models/workarea/storefront/checkout/summary_view_model.rb

Instance Method Summary collapse

Methods included from OrderPricing

#advance_payment_amount, #order_balance, #store_credit?, #store_credit_amount, #total_adjustments

Instance Method Details

#billing_addressAddress

The current billing address.

Returns:

  • (Address)


34
35
36
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 34

def billing_address
  payment.address || Address.new
end

#shipping_addressShipping::Address

The current shipping address

Returns:

  • (Shipping::Address)


42
43
44
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 42

def shipping_address
  shipping.try(:address)
end

#shipping_serviceString?

The current shipping service display name

Returns:

  • (String, nil)


50
51
52
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 50

def shipping_service
  shipping.try(:shipping_service).try(:name)
end

#shippingsObject



14
15
16
17
18
19
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 14

def shippings
  @shippings ||= Storefront::ShippingViewModel.wrap(
    model.shippings,
    options
  )
end

#show_addresses?Boolean

Whether to show the addresses summaries. Based on Checkout::Steps::Addresses#complete?

Returns:

  • (Boolean)


26
27
28
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 26

def show_addresses?
  addresses_complete?
end

#show_shipping_address?Boolean

Whether we should show info about shipping address. True as long as the order requires shipping.

Returns:

  • (Boolean)


59
60
61
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 59

def show_shipping_address?
  order.requires_shipping?
end

#show_shipping_options?Boolean Also known as: shipping_determined?, show_shipping_service?

Whether to show shipping service info in the summary.

Returns:

  • (Boolean)


67
68
69
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 67

def show_shipping_options?
  order.requires_shipping? && shippings.any?(&:show_options?)
end

#taxes_determined?Boolean

Whether the tax total has been determined yet.

Returns:

  • (Boolean)


77
78
79
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 77

def taxes_determined?
  addresses_complete?
end