Sha256: c3ddf02e9491efe5735e7d82715ce8b3a0fd532ab45bee44637389f52b783b45

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

module Workarea
  decorate Storefront::OrderItemViewModel, with: :flow_io do
    def original_unit_price
      return super unless order.experience.present?

      return 0.to_m(order.currency) if flow_price_adjustments.blank?
      flow_price_adjustments.first.unit.to_m
    end

    def total_price
      return super unless order.experience.present?

      model.flow_total_price
    end

    def flow_price_adjustments
      @flow_price_adjustments ||= FlowPriceAdjustmentSet.new(
        model.flow_price_adjustments,
        order.experience
      )
    end

    def total_adjustments
      return super unless order.experience.present?

      @total_adjustments ||= flow_price_adjustments.reduce_by_description('item')
    end

    def original_price
      return super unless order.experience.present?

      flow_price_adjustments.first.data['original_price'].to_m(order.currency)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-flow_io-1.2.1 app/view_models/workarea/storefront/order_item_view_model.decorator