Class: Workarea::Storefront::AfterpayViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Storefront::AfterpayViewModel
- Defined in:
- app/view_models/workarea/storefront/afterpay_view_model.rb
Instance Method Summary collapse
- #afterpay_country ⇒ Object
- #installment_price ⇒ Object
- #max_price ⇒ Object
- #min_price ⇒ Object
-
#order_total_in_range? ⇒ Boolean
Orders must be between the min and max order total to qualify.
-
#show? ⇒ Boolean
Show if admin settings are enabled, there are configuration options returned from the API and the currency code is valid.
- #show_on_cart? ⇒ Boolean
- #show_on_pdp? ⇒ Boolean
Instance Method Details
#afterpay_country ⇒ Object
41 42 43 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 41 def afterpay_country Workarea.config.afterpay[:currency_country_map][currency.to_sym] end |
#installment_price ⇒ Object
28 29 30 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 28 def installment_price order.order_balance / Workarea.config.afterpay[:installment_count] end |
#max_price ⇒ Object
37 38 39 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 37 def max_price afterpay_configuration[:maximumAmount][:amount].to_m end |
#min_price ⇒ Object
32 33 34 35 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 32 def min_price return 0.to_m unless afterpay_configuration[:minimumAmount].present? afterpay_configuration[:minimumAmount][:amount].to_m end |
#order_total_in_range? ⇒ Boolean
Orders must be between the min and max order total to qualify.
5 6 7 8 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 5 def order_total_in_range? return unless afterpay_configuration.present? order.order_balance >= min_price && order.order_balance <= max_price end |
#show? ⇒ Boolean
Show if admin settings are enabled, there are configuration options returned from the API and the currency code is valid.
12 13 14 15 16 17 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 12 def show? return unless afterpay_settings.enabled? return unless valid_international_order? return unless afterpay_configuration.present? afterpay_country.present? end |
#show_on_cart? ⇒ Boolean
19 20 21 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 19 def show_on_cart? show? && afterpay_settings.display_on_cart? end |
#show_on_pdp? ⇒ Boolean
23 24 25 |
# File 'app/view_models/workarea/storefront/afterpay_view_model.rb', line 23 def show_on_pdp? show? && afterpay_settings.display_on_pdp? end |