Class: Workarea::Storefront::Checkout::SummaryViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Storefront::Checkout::SummaryViewModel
- Includes:
- OrderPricing
- Defined in:
- app/view_models/workarea/storefront/checkout/summary_view_model.rb
Instance Method Summary collapse
-
#billing_address ⇒ Address
The current billing address.
-
#shipping_address ⇒ Shipping::Address
The current shipping address.
-
#shipping_service ⇒ String?
The current shipping service display name.
- #shippings ⇒ Object
-
#show_addresses? ⇒ Boolean
Whether to show the addresses summaries.
-
#show_shipping_address? ⇒ Boolean
Whether we should show info about shipping address.
-
#show_shipping_options? ⇒ Boolean
(also: #shipping_determined?, #show_shipping_service?)
Whether to show shipping service info in the summary.
-
#taxes_determined? ⇒ Boolean
Whether the tax total has been determined yet.
Methods included from OrderPricing
#advance_payment_amount, #order_balance, #store_credit?, #store_credit_amount, #total_adjustments
Instance Method Details
#billing_address ⇒ Address
The current billing 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_address ⇒ Shipping::Address
The current 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_service ⇒ String?
The current shipping service display name
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 |
#shippings ⇒ Object
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, ) end |
#show_addresses? ⇒ Boolean
Whether to show the addresses summaries. Based on Checkout::Steps::Addresses#complete?
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.
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.
67 68 69 |
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 67 def order.requires_shipping? && shippings.any?(&:show_options?) end |
#taxes_determined? ⇒ Boolean
Whether the tax total has been determined yet.
77 78 79 |
# File 'app/view_models/workarea/storefront/checkout/summary_view_model.rb', line 77 def taxes_determined? addresses_complete? end |