Sha256: a75a8fd326e3420cd5cc9c8779f062522af4b301e3ee4fc6c2a6d3ed3c98101a
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module SolidusConfigurableKits class PriceSelector < ::Spree::Variant::PriceSelector def self.pricing_options_class SolidusConfigurableKits::PricingOptions end # The variant's price, given a set of pricing options # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by # @return [Spree::Money, nil] The most specific price for this set of pricing options. def price_for(price_options) ::Spree::Deprecation.warn( "price_for is deprecated and will be removed. The price_for method should return a Spree::Price as described. Please use #price_for_options and adjust your frontend code to explicitly call &.money where required" ) price_for_options(price_options)&.money end # The variant's Spree::Price record, given a set of pricing options # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by # @return [Spree::Price, nil] The most specific price for this set of pricing options. def price_for_options(price_options) variant.currently_valid_prices.detect do |price| (price.country_iso == price_options.desired_attributes[:country_iso] || price.country_iso.nil? ) && price.currency == price_options.desired_attributes[:currency] && price.kit_item == price_options.desired_attributes[:kit_item] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_configurable_kits-0.1.1 | app/services/solidus_configurable_kits/price_selector.rb |
solidus_configurable_kits-0.1.0 | app/services/solidus_configurable_kits/price_selector.rb |