Module: Workarea::Storefront::ProductsHelper

Defined in:
app/helpers/workarea/storefront/products_helper.rb

Instance Method Summary collapse

Instance Method Details

#intrinsic_ratio_product_image_styles(image) ⇒ Object



37
38
39
40
# File 'app/helpers/workarea/storefront/products_helper.rb', line 37

def intrinsic_ratio_product_image_styles(image)
  return if image.inverse_aspect_ratio.blank?
  "padding-bottom: #{image.inverse_aspect_ratio * 100}%;"
end

#option_label(option) ⇒ Object



20
21
22
23
24
25
26
# File 'app/helpers/workarea/storefront/products_helper.rb', line 20

def option_label(option)
  if option.current.present?
    "#{option.name}: #{option.current}"
  else
    option.name
  end
end

#option_selection_url_for(product, option, selection) ⇒ Object



28
29
30
31
32
33
34
35
# File 'app/helpers/workarea/storefront/products_helper.rb', line 28

def option_selection_url_for(product, option, selection)
  selection_value = option.current == selection ? nil : selection
  product.currently_selected_options.merge(
    option.slug => selection_value,
    id: product.slug,
    via: params[:via]
  )
end

#truncated_product_description(product, text) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/workarea/storefront/products_helper.rb', line 4

def truncated_product_description(product, text)
  truncate(strip_tags(product.description), length: 200) do
    link_to(
      text,
      product_path(
        product,
        params: product.browse_link_options,
        anchor: 'description'
      ),
      data: {
        scroll_to_button: ''
      }
    )
  end
end