Sha256: 069337bc83f5a8b2bb7633b0b65ba6a968d9051b68959b9c93c5e1e101db149c
Contents?: true
Size: 900 Bytes
Versions: 2
Compression:
Stored size: 900 Bytes
Contents
module Spree module EdronesHelper def product_for_segment(product, optional = {}) { product_id: product.id, sku: product.sku, category: product.category.try(:name), category_id: product.category.try(:id), name: product.name, brand: product.brand.try(:name), price: product.price.to_f, currency: product.currency, url: product_url(product), }.tap do |hash| if defined?(ActiveStorage) && !Rails.application.config.use_paperclip hash[:image_url] = request.base_url + Rails.application.routes.url_helpers.rails_blob_path(optional.delete(:image).attachment, only_path: true) if optional[:image] else hash[:image_url] = request.base_url + asset_url(optional.delete(:image).attachment) if optional[:image] end end.merge(optional).to_json.html_safe end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_edrone-1.0.2 | app/helpers/spree/edrones_helper.rb |
spree_edrone-1.0.1 | app/helpers/spree/edrones_helper.rb |