Class: SolidusGraphqlApi::Mutations::Checkout::AddAddressesToCheckout
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- SolidusGraphqlApi::Mutations::Checkout::AddAddressesToCheckout
- Defined in:
- lib/solidus_graphql_api/mutations/checkout/add_addresses_to_checkout.rb
Instance Method Summary collapse
- #ready? ⇒ Boolean
- #resolve(billing_address:, shipping_address: nil, ship_to_billing_address: false) ⇒ Object
Instance Method Details
#ready? ⇒ Boolean
35 36 37 |
# File 'lib/solidus_graphql_api/mutations/checkout/add_addresses_to_checkout.rb', line 35 def ready?(*) current_ability.(:update, current_order, guest_token) end |
#resolve(billing_address:, shipping_address: nil, ship_to_billing_address: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/solidus_graphql_api/mutations/checkout/add_addresses_to_checkout.rb', line 16 def resolve(billing_address:, shipping_address: nil, ship_to_billing_address: false) current_order.update(state: :address) update_params = { bill_address: Spree::Address.new(billing_address.to_h), ship_address: Spree::Address.new(shipping_address.to_h), use_billing: ship_to_billing_address } if Spree::OrderUpdateAttributes.new(current_order, update_params).apply current_order.recalculate errors = [] else errors = current_order.errors end { errors: user_errors('order', errors), order: current_order } end |