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
15
16
17
18
19
20
# File 'app/models/spree/order_contents.rb', line 9

def add(variant, quantity = 1, options = {})
  ActiveSupport::Deprecation.warn(<<-EOS, caller)
    OrderContents#add method is deprecated and will be removed in Spree 4.0.
    Please use Spree::Dependencies.cart_add_item_service
    to add items to cart.
  EOS

  Spree::Dependencies.cart_add_item_service.constantize.call(order: order,
                                                             variant: variant,
                                                             quantity: quantity,
                                                             options: options).value
end

#remove(variant, quantity = 1, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/spree/order_contents.rb', line 22

def remove(variant, quantity = 1, options = {})
  ActiveSupport::Deprecation.warn(<<-EOS, caller)
    OrderContents#remove method is deprecated and will be removed in Spree 4.0.
    Please use Spree::Dependencies.cart_remove_item_service
    service to remove item from cart.
  EOS

  # change this dependencies to Spree::Cart::RemoveItem
  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



36
37
38
39
40
41
42
# File 'app/models/spree/order_contents.rb', line 36

def remove_line_item(line_item, options = {})
  ActiveSupport::Deprecation.warn(<<-EOS, caller)
    OrderContents#remove_line_item method is deprecated and will be removed in Spree 4.0.
  EOS

  Spree::Cart::RemoveLineItem.call(order: @order, line_item: line_item, options: options).value
end

#update_cart(params) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'app/models/spree/order_contents.rb', line 44

def update_cart(params)
  ActiveSupport::Deprecation.warn(<<-EOS, caller)
    OrderContents#update_cart method is deprecated and will be removed in Spree 4.0.
    Spree::Dependencies.cart_update_service
    service to update cart.
  EOS

  Spree::Dependencies.cart_update_service.constantize.call(order: order, params: params).value
end