Class: Spree::LineItem
Instance Attribute Summary collapse
Instance Method Summary
collapse
money_methods
Methods inherited from Base
page, spree_base_scopes
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Attribute Details
#target_shipment ⇒ Object
Returns the value of attribute target_shipment.
37
38
39
|
# File 'app/models/spree/line_item.rb', line 37
def target_shipment
@target_shipment
end
|
Instance Method Details
#amount ⇒ Object
Also known as:
subtotal
66
67
68
|
# File 'app/models/spree/line_item.rb', line 66
def amount
price * quantity
end
|
#copy_price ⇒ Object
42
43
44
45
46
47
48
|
# File 'app/models/spree/line_item.rb', line 42
def copy_price
if variant
update_price if price.nil?
self.cost_price = variant.cost_price if cost_price.nil?
self.currency = variant.currency if currency.nil?
end
end
|
#copy_tax_category ⇒ Object
54
55
56
57
58
|
# File 'app/models/spree/line_item.rb', line 54
def copy_tax_category
if variant
self.tax_category = variant.tax_category
end
end
|
#final_amount ⇒ Object
Also known as:
total
79
80
81
|
# File 'app/models/spree/line_item.rb', line 79
def final_amount
amount + adjustment_total
end
|
#insufficient_stock? ⇒ Boolean
95
96
97
|
# File 'app/models/spree/line_item.rb', line 95
def insufficient_stock?
!sufficient_stock?
end
|
#invalid_quantity_check ⇒ Object
86
87
88
89
|
# File 'app/models/spree/line_item.rb', line 86
def invalid_quantity_check
warn "`invalid_quantity_check` is deprecated. Use private `ensure_valid_quantity` instead."
ensure_valid_quantity
end
|
#options=(options = {}) ⇒ Object
99
100
101
102
103
104
105
106
107
108
|
# File 'app/models/spree/line_item.rb', line 99
def options=(options = {})
return unless options.present?
opts = options.dup
currency = opts.delete(:currency) || order.try(:currency)
update_price_from_modifier(currency, opts)
assign_attributes opts
end
|
#sufficient_stock? ⇒ Boolean
#taxable_amount ⇒ Object
Also known as:
discounted_amount
72
73
74
|
# File 'app/models/spree/line_item.rb', line 72
def taxable_amount
amount + taxable_adjustment_total
end
|
#update_price ⇒ Object
50
51
52
|
# File 'app/models/spree/line_item.rb', line 50
def update_price
self.price = variant.price_including_vat_for(tax_zone: tax_zone)
end
|