Class: SpreeGoogleAnalytics::ProductPresenter
- Inherits:
-
Object
- Object
- SpreeGoogleAnalytics::ProductPresenter
- Includes:
- Spree::BaseHelper, Spree::ProductsHelper
- Defined in:
- app/presenters/spree_google_analytics/product_presenter.rb
Instance Method Summary collapse
- #call ⇒ Hash
-
#initialize(resource:, quantity:, position: nil, store_name: nil) ⇒ ProductPresenter
constructor
A new instance of ProductPresenter.
Constructor Details
#initialize(resource:, quantity:, position: nil, store_name: nil) ⇒ ProductPresenter
Returns a new instance of ProductPresenter.
10 11 12 13 14 15 |
# File 'app/presenters/spree_google_analytics/product_presenter.rb', line 10 def initialize(resource:, quantity:, position: nil, store_name: nil) @resource = resource @quantity = quantity @position = position @store_name = store_name end |
Instance Method Details
#call ⇒ Hash
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/presenters/spree_google_analytics/product_presenter.rb', line 18 def call { item_id: @resource.sku.presence || @resource.product_id, item_name: @resource.name, affiliation: @resource.respond_to?(:order) && @resource.order&.store.present? ? @resource.order.store.name : @store_name, discount: 0.00, index: @position.to_s, item_brand: @resource.product.present? ? @resource.product.brand_name.to_s : '', item_category: taxons[0].to_s, item_category2: taxons[1].to_s, item_category3: taxons[2].to_s, item_category4: taxons[3].to_s, item_category5: taxons[4].to_s, item_list_id: '', item_list_name: '', item_variant: @resource.try(:options_text), location_id: '', price: @resource.price.to_f, quantity: @quantity }.merge(try_promotion_codes_applied_to_line_item) end |