Class: Spree::LineItem
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- Base
- Spree::LineItem
show all
- Defined in:
- app/models/spree/line_item.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
page
#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.
36
37
38
|
# File 'app/models/spree/line_item.rb', line 36
def target_shipment
@target_shipment
end
|
Instance Method Details
#adjust_quantity ⇒ Object
80
81
82
|
# File 'app/models/spree/line_item.rb', line 80
def adjust_quantity
self.quantity = 0 if quantity.nil? || quantity < 0
end
|
#amount ⇒ Object
Also known as:
subtotal
55
56
57
|
# File 'app/models/spree/line_item.rb', line 55
def amount
price * quantity
end
|
#copy_price ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/models/spree/line_item.rb', line 41
def copy_price
if variant
self.price = variant.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
49
50
51
52
53
|
# File 'app/models/spree/line_item.rb', line 49
def copy_tax_category
if variant
self.tax_category = variant.tax_category
end
end
|
#discounted_amount ⇒ Object
60
61
62
|
# File 'app/models/spree/line_item.rb', line 60
def discounted_amount
amount + promo_total
end
|
#final_amount ⇒ Object
Also known as:
total
64
65
66
|
# File 'app/models/spree/line_item.rb', line 64
def final_amount
amount + adjustment_total.to_f
end
|
#insufficient_stock? ⇒ Boolean
88
89
90
|
# File 'app/models/spree/line_item.rb', line 88
def insufficient_stock?
!sufficient_stock?
end
|
#money ⇒ Object
Also known as:
display_total, display_amount
74
75
76
|
# File 'app/models/spree/line_item.rb', line 74
def money
Spree::Money.new(amount, { currency: currency })
end
|
#product ⇒ Object
Remove product default_scope ‘deleted_at: nil`
93
94
95
|
# File 'app/models/spree/line_item.rb', line 93
def product
variant.product
end
|
#single_money ⇒ Object
Also known as:
single_display_amount
69
70
71
|
# File 'app/models/spree/line_item.rb', line 69
def single_money
Spree::Money.new(price, { currency: currency })
end
|
#sufficient_stock? ⇒ Boolean
#variant ⇒ Object
Remove variant default_scope ‘deleted_at: nil`
98
99
100
|
# File 'app/models/spree/line_item.rb', line 98
def variant
Spree::Variant.unscoped { super }
end
|