Class: Spree::WishlistsController

Inherits:
StoreController show all
Defined in:
app/controllers/spree/wishlists_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?, #visitor_id

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

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/spree/wishlists_controller.rb', line 3

def show
  if params[:id].present? && params[:token].present?
    @wishlist = current_store.wishlists.find_by!(id: params[:id], token: params[:token])
  elsif try_spree_current_user
    # https://github.com/spree/spree/blob/9475c6633b762669ee0c8f1f8a4d73e1c221a94e/core/app/models/concerns/spree/user_methods.rb#L71
    @wishlist = try_spree_current_user.default_wishlist_for_store(current_store)
  else
    return require_user
  end

  @wished_items = @wishlist.wished_items.includes(
    product: [:prices_including_master, :variants, :master, :taggings],
    variant: [:images, :product, { option_values: :option_type }]
  )
end