Sha256: 8d45ca32d89436aa8fc2a88345860d1c30500eef2bdbb3559531096f709b30b7
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Workarea module Kount class RisInquiry::Product attr_reader :order_item def initialize(order_item) @order_item = order_item end def item order_item.sku end def type catalog_product.name end def description "#{catalog_product.name} - #{variant_description}".truncate(255) end def quantity order_item.quantity end def price order_item.unit_price_cents.floor end private def catalog_product @catalog_product ||= if order_item.product_attributes.present? Mongoid::Factory.from_db(Catalog::Product, order_item.product_attributes) else Catalog::Product.find_by_sku(order_item.sku) end end def variant catalog_product.variants.where(sku: order_item.sku).first end def variant_description variant .details .map { |key, value| "#{key}: #{value.join(',')}" } .flatten.join(', ') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-kount-3.3.1 | app/services/workarea/kount/ris_inquiry/product.rb |
workarea-kount-3.3.0 | app/services/workarea/kount/ris_inquiry/product.rb |