Sha256: ce66511977c95b31f9fe9df54f0b98c8d4e7a62a5e05ff89d44cea2d74f3d244
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module Workarea decorate Admin::ProductViewModel, with: :product_bundles do decorated do include Admin::FeaturedProductsViewModel end def variant_details? variant_details.present? end def bundled_products @bundled_products ||= begin models = Catalog::Product.find_ordered_for_display( model.product_ids ) Admin::ProductViewModel.wrap(models) end end def bundled_product_sku_options bundled_products.flat_map do |product| product.variants.map do |variant| [ [ variant.sku, variant.details.flat_map { |k, v| "#{k}: #{v.to_sentence}" } ].join(' '), variant.sku, data: { variant_component_option: product.id } ] end end end def bundle_templates Workarea.config.product_bundle_templates .map(&:to_s) .map do |template_name| [template_name.titleize, template_name.optionize] end end def templates return super unless model.present? if discrete_bundle? bundle_templates else super.reject { |o| o.in?(bundle_templates) } end end def inventory_message return super unless discrete_bundle? @bundle_inventory_message ||= if !active? t('workarea.admin.featured_products.statuses.inactive') else '' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-product_bundles-1.0.1 | app/view_models/workarea/admin/product_view_model.decorator |
workarea-product_bundles-1.0.0 | app/view_models/workarea/admin/product_view_model.decorator |