Module: SolidusConfigurableKits::Spree::VariantDecorator::ClassMethods

Defined in:
app/decorators/models/solidus_configurable_kits/spree/variant_decorator.rb

Instance Method Summary collapse

Instance Method Details

#with_prices(pricing_options = ::Spree::Config.default_pricing_options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/decorators/models/solidus_configurable_kits/spree/variant_decorator.rb', line 7

def with_prices(pricing_options = ::Spree::Config.default_pricing_options)
  query = "    spree_prices.currency = ? AND\n      spree_prices.kit_item = ? AND\n      (spree_prices.country_iso IS NULL OR spree_prices.country_iso = ?)\n  SQL\n  where(\n    ::Spree::Price.\n      where(::Spree::Variant.arel_table[:id].eq(::Spree::Price.arel_table[:variant_id])).\n      # This next clause should just be `where(pricing_options.search_arguments)`, but ActiveRecord\n      # generates invalid SQL, so the SQL here is written manually.\n      where(\n        query,\n        pricing_options.search_arguments[:currency],\n        pricing_options.search_arguments[:kit_item],\n        pricing_options.search_arguments[:country_iso].compact\n      ).\n      arel.exists\n  )\nend\n"