Module: Workarea::Search::Storefront::Product::Pricing

Included in:
Workarea::Search::Storefront::Product
Defined in:
app/models/workarea/search/storefront/product/pricing.rb

Instance Method Summary collapse

Instance Method Details

#on_sale?Boolean

Whether or not the product is considered on sale. Determined by having a pricing sku that is set to be on sale.

Returns:

  • (Boolean)


38
39
40
# File 'app/models/workarea/search/storefront/product/pricing.rb', line 38

def on_sale?
  pricing.on_sale?
end

#priceArray

The prices of this product for the search index. It is the collection of sellable prices for any SKUs that belong to the product if price ranges are enabled. Otherwise it is the lowest sellable price for any SKUs that belong to the product. Converted to a float so JSON encoding is not applied to Money when being put into the index.

Returns:

  • (Array)


25
26
27
28
29
30
31
# File 'app/models/workarea/search/storefront/product/pricing.rb', line 25

def price
  if pricing.all_selling_prices.present?
    pricing.all_selling_prices.map(&:to_f)
  else
    [0.0]
  end
end

#pricingPricing::Collection

The product pricing based on the available SKUs to get the correct index data.

Returns:



47
48
49
50
51
# File 'app/models/workarea/search/storefront/product/pricing.rb', line 47

def pricing
  @pricing ||= Workarea::Pricing::Collection.new(
    skus_with_displayable_inventory
  )
end

#sort_priceFloat

The price of this product for the search index used for sorting. It is the lowest sellable price for any SKUs that belong to the product. Converted to a float so JSON encoding is not applied to Money when being put into the index.

Returns:



13
14
15
# File 'app/models/workarea/search/storefront/product/pricing.rb', line 13

def sort_price
  pricing.sell_min_price.to_f
end