Class: SpreeKlaviyo::ShipmentPresenter
- Inherits:
-
OrderPresenter
- Object
- OrderPresenter
- SpreeKlaviyo::ShipmentPresenter
- Includes:
- Spree::BaseHelper, Spree::ImagesHelper, Spree::ProductsHelper
- Defined in:
- app/presenters/spree_klaviyo/shipment_presenter.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(shipment:, order: nil, store: nil) ⇒ ShipmentPresenter
constructor
A new instance of ShipmentPresenter.
Constructor Details
#initialize(shipment:, order: nil, store: nil) ⇒ ShipmentPresenter
Returns a new instance of ShipmentPresenter.
8 9 10 11 12 |
# File 'app/presenters/spree_klaviyo/shipment_presenter.rb', line 8 def initialize(shipment:, order: nil, store: nil) @shipment = shipment @order = order || shipment.order @current_store = store || order.store || shipment.store end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/presenters/spree_klaviyo/shipment_presenter.rb', line 14 def call { customer_name: @order.name || ::Spree.t('customer'), email: @order&.user&.email || @order.email, order_number: @order.number, shipping_method: shipping_method_name(@shipment), tracking: @shipment&.tracking.to_s, tracking_url: @shipment&.tracking_url, store_name: @current_store.name, cost: @shipment.final_price.to_f, completed_at: @order.completed_at&.iso8601.to_s, shipped_items: shipped_items, bill_address: AddressPresenter.new(address: @order.bill_address).call, ship_address: AddressPresenter.new(address: @order.ship_address).call } end |