Class: Gemgento::LineItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gemgento::LineItem
- Defined in:
- app/models/gemgento/line_item.rb
Overview
Instance Attribute Summary collapse
-
#async ⇒ Object
Returns the value of attribute async.
-
#destroy_quote_after_rollback ⇒ Object
Returns the value of attribute destroy_quote_after_rollback.
Instance Method Summary collapse
-
#as_json(options = nil) ⇒ Void
JSON representation of the LineItem.
-
#price ⇒ BigDecimal
Get the associated Product price.
Instance Attribute Details
#async ⇒ Object
Returns the value of attribute async.
9 10 11 |
# File 'app/models/gemgento/line_item.rb', line 9 def async @async end |
#destroy_quote_after_rollback ⇒ Object
Returns the value of attribute destroy_quote_after_rollback.
9 10 11 |
# File 'app/models/gemgento/line_item.rb', line 9 def destroy_quote_after_rollback @destroy_quote_after_rollback end |
Instance Method Details
#as_json(options = nil) ⇒ Void
JSON representation of the LineItem.
34 35 36 37 38 |
# File 'app/models/gemgento/line_item.rb', line 34 def as_json( = nil) result = super result['product'] = self.product.as_json({ store: Store.find(self.itemizable.store.id) }) return result end |
#price ⇒ BigDecimal
Get the associated Product price.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/gemgento/line_item.rb', line 43 def price return super.to_d unless super.nil? if product.magento_type == 'giftvoucher' self.[:amount].to_d elsif self.[:custom_price] self.[:custom_price].to_d else user_group = itemizable.user ? itemizable.user.user_group : nil product.price(user_group, itemizable.store, self.qty_ordered).to_d end end |