Class: Spree::OrderContents

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/order_contents.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#currencyObject

Returns the value of attribute currency.



3
4
5
# File 'app/models/spree/order_contents.rb', line 3

def currency
  @currency
end

#orderObject

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, options = {})
  Spree::Dependencies.cart_add_item_service.constantize.call(order: order,
                                                             variant: variant,
                                                             quantity: quantity,
                                                             options: 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, options = {})
  Spree::Dependencies.cart_remove_item_service.constantize.call(order: order,
                                                                variant: variant,
                                                                quantity: quantity,
                                                                options: 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, options = {})
  Spree::Cart::RemoveLineItem.call(order: @order, line_item: line_item, options: 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