Class: Spree::OrderContents
- Inherits:
-
Object
- Object
- Spree::OrderContents
- Defined in:
- app/models/spree/order_contents.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#order ⇒ Object
Returns the value of attribute order.
Instance Method Summary collapse
- #add(variant, quantity = 1, options = {}) ⇒ Object
-
#initialize(order) ⇒ OrderContents
constructor
A new instance of OrderContents.
- #remove(variant, quantity = 1, options = {}) ⇒ Object
- #remove_line_item(line_item, options = {}) ⇒ Object
- #update_cart(params) ⇒ Object
Constructor Details
#initialize(order) ⇒ OrderContents
Returns a new instance of OrderContents.
5 6 7 |
# File 'app/models/spree/order_contents.rb', line 5 def initialize(order) @order = order end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'app/models/spree/order_contents.rb', line 3 def currency @currency end |
#order ⇒ Object
Returns the value of attribute order.
3 4 5 |
# File 'app/models/spree/order_contents.rb', line 3 def order @order end |
Instance Method Details
#add(variant, quantity = 1, options = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'app/models/spree/order_contents.rb', line 9 def add(variant, quantity = 1, = {}) Spree::Dependencies.cart_add_item_service.constantize.call(order: order, variant: variant, quantity: quantity, options: ).value end |
#remove(variant, quantity = 1, options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'app/models/spree/order_contents.rb', line 16 def remove(variant, quantity = 1, = {}) Spree::Dependencies.cart_remove_item_service.constantize.call(order: order, variant: variant, quantity: quantity, options: ).value end |
#remove_line_item(line_item, options = {}) ⇒ Object
23 24 25 |
# File 'app/models/spree/order_contents.rb', line 23 def remove_line_item(line_item, = {}) Spree::Cart::RemoveLineItem.call(order: @order, line_item: line_item, options: ).value end |
#update_cart(params) ⇒ Object
27 28 29 |
# File 'app/models/spree/order_contents.rb', line 27 def update_cart(params) Spree::Dependencies.cart_update_service.constantize.call(order: order, params: params).value end |