Class: SolidusGraphqlApi::Mutations::Checkout::RemoveFromCart

Inherits:
BaseMutation
  • Object
show all
Defined in:
lib/solidus_graphql_api/mutations/checkout/remove_from_cart.rb

Instance Method Summary collapse

Instance Method Details

#authorized?(line_item:) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/solidus_graphql_api/mutations/checkout/remove_from_cart.rb', line 23

def authorized?(line_item:)
  current_order.line_items.find(line_item.id)
end

#ready?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/solidus_graphql_api/mutations/checkout/remove_from_cart.rb', line 27

def ready?(*)
  current_ability.authorize!(:update, current_order, guest_token)
end

#resolve(line_item:) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/solidus_graphql_api/mutations/checkout/remove_from_cart.rb', line 14

def resolve(line_item:)
  line_item = current_order.contents.remove_line_item(line_item)

  {
    order: current_order,
    errors: user_errors("line_item", line_item.errors)
  }
end