Class: Spree::OrdersController

Inherits:
StoreController show all
Includes:
CartMethods, Core::ControllerHelpers::Order
Defined in:
app/controllers/spree/orders_controller.rb

Instance Method Summary collapse

Methods inherited from StoreController

#current_taxon, #default_products_sort, #permitted_products_params, #products_filters_params, #render_404_if_store_not_exists, #store_filter_names, #store_filter_names_hash

Methods included from AnalyticsHelper

#analytics_event_handlers, #track_event, #unsupported_event?

Methods included from WishlistHelper

#current_wishlist

Methods included from PasswordProtected

#redirect_to_password

Methods included from StorefrontHelper

#as_aspect_ratio, #page_description, #page_image, #paths_equal?, #render_storefront_partials, #show_account_pane?, #svg_country_icon, #tailwind_classes_for

Methods included from ThemeConcern

#default_url_options, #set_theme_view_paths

Instance Method Details

#editObject

GET /cart



40
41
42
43
44
45
46
47
# File 'app/controllers/spree/orders_controller.rb', line 40

def edit
  flash.keep if request.format.turbo_stream?
  @order = current_order || find_order_by_cookie
  associate_user

  remove_out_of_stock_items
  load_line_items
end

#showObject

GET /orders/:id

Raises:

  • (ActiveRecord::RecordNotFound)


14
15
16
17
18
19
20
# File 'app/controllers/spree/orders_controller.rb', line 14

def show
  @order = complete_order_finder.new(number: params[:id], token: params[:token], store: current_store).execute.first

  raise ActiveRecord::RecordNotFound if @order.blank? || !authorize_access

  @shipments = @order.shipments.includes(:stock_location, :address, selected_shipping_rate: :shipping_method, inventory_units: :line_item)
end

#updateObject

PUT /cart



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/spree/orders_controller.rb', line 23

def update
  @variant = current_store.variants.find(params[:variant_id]) if params[:variant_id]
  @result = cart_update_service.call(order: @order, params: order_params)

  if @result.success?
    if params.key?(:checkout)
      @order.next if @order.cart?
      redirect_to spree.checkout_state_path(@order.token, @order.checkout_steps.first)
    else
      redirect_to spree.cart_path
    end
  else
    render :edit, status: :unprocessable_entity
  end
end