Sha256: 939dab9fb24ea70cb870541d2957a307959a25604fda32d5c73813f9cecbd5de

Contents?: true

Size: 894 Bytes

Versions: 3

Compression:

Stored size: 894 Bytes

Contents

module Workarea
  module Storefront
    class ProductTemplates::PackageViewModel < ProductViewModel
      delegate :has_price_range?, :price, :display_min_price,
               :display_max_price, :display_price, :has_msrp_range?,
               :msrp?, :msrp, :msrp_min, :msrp_max, :sale_starts_at,
               :sale_ends_at, to: :pricing

      def primary_image
        product_image = super
        return product_image unless product_image.placeholder?

        @primary_image ||=
          packaged_products
          .map(&:images)
          .flatten
          .reject(&:placeholder?)
          .first ||
          Catalog::ProductPlaceholderImage.cached
      end

      def show_panel?
        false
      end

      def pricing
        @pricing ||=
          options[:pricing] ||
          Pricing::Collection.new(packaged_products.map(&:skus).flatten)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-package_products-3.4.1 app/view_models/workarea/storefront/product_templates/package_view_model.rb
workarea-package_products-3.4.0 app/view_models/workarea/storefront/product_templates/package_view_model.rb
workarea-package_products-3.3.3 app/view_models/workarea/storefront/product_templates/package_view_model.rb