Class: Cartify::Order
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Cartify::Order
- Defined in:
- app/models/cartify/order.rb
Instance Method Summary collapse
- #discount ⇒ Object
- #finalize ⇒ Object
- #shipping_price ⇒ Object
- #subtotal ⇒ Object
- #subtotal_item_total ⇒ Object
- #total ⇒ Object
Instance Method Details
#discount ⇒ Object
33 34 35 |
# File 'app/models/cartify/order.rb', line 33 def discount coupon.try(:value) || 0.00 end |
#finalize ⇒ Object
41 42 43 44 |
# File 'app/models/cartify/order.rb', line 41 def finalize set_order_status :in_queue save! end |
#shipping_price ⇒ Object
37 38 39 |
# File 'app/models/cartify/order.rb', line 37 def shipping_price delivery.try(:price) || 0.00 end |
#subtotal ⇒ Object
21 22 23 |
# File 'app/models/cartify/order.rb', line 21 def subtotal order_items.sum(&:total_price) end |
#subtotal_item_total ⇒ Object
29 30 31 |
# File 'app/models/cartify/order.rb', line 29 def subtotal_item_total subtotal - discount end |
#total ⇒ Object
25 26 27 |
# File 'app/models/cartify/order.rb', line 25 def total subtotal_item_total + shipping_price end |