Method: Spree::LineItem#options=

Defined in:
app/models/spree/line_item.rb

#options=(options = {}) ⇒ Object

Sets the options on the line item according to the order’s currency or one passed in.

Parameters:

  • options (Hash) (defaults to: {})

    options for this line item



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'app/models/spree/line_item.rb', line 135

def options=(options={})
  return unless options.present?

  opts = options.dup # we will be deleting from the hash, so leave the caller's copy intact

  currency = opts.delete(:currency) || order.try(:currency)

  if currency
    self.currency = currency
    self.price    = variant.price_in(currency).amount +
                    variant.price_modifier_amount_in(currency, opts)
  else
    self.price    = variant.price +
                    variant.price_modifier_amount(opts)
  end

  self.assign_attributes opts
end