Sha256: a6581c81fe20552aa892c06558467e193bee11cc2ba1faa1f924fd756d853764
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
module Workarea decorate Storefront::ProductViewModel, with: :afterpay do decorated do include Storefront::AfterpayConfiguration end def show_afterpay? return unless pricing.has_prices? return unless afterpay_settings.enabled? && afterpay_settings.display_on_pdp? return unless afterpay_location_configuration.present? pricing.sell_min_price >= min_price && pricing.sell_min_price <= max_price end def installment_price pricing.sell_min_price / Workarea::Afterpay.config[:installment_count] end private def min_price return 0.to_m unless afterpay_location_configuration[:minimumAmount].present? afterpay_location_configuration[:minimumAmount][:amount].to_m end def max_price afterpay_location_configuration[:maximumAmount][:amount].to_m end def afterpay_location currency = pricing.sell_min_price.currency.iso_code location = Workarea::Afterpay.config[:currency_country_map][currency.to_sym] return unless location.present? location.to_sym.downcase end def afterpay_location_configuration afterpay_configuration(afterpay_location).with_indifferent_access end def afterpay_settings @afterpay_settings ||= Workarea::Afterpay::Configuration.current end end end
Version data entries
3 entries across 3 versions & 1 rubygems