Class: Store::OrdersController

Inherits:
StoreController
  • Object
show all
Includes:
ActionView::Helpers::TextHelper, ArtfullyOseHelper
Defined in:
app/controllers/store/orders_controller.rb

Instance Method Summary collapse

Methods included from ArtfullyOseHelper

#amount_and_nongift, #bootstrapped_type, #build_action_path, #build_order_location, #channel_checkbox, #channel_text, #check_mark, #clean_full_error_messages, #contextual_menu, #credit_card_message, #date_field_tag, #datetime_field_tag, #events_to_options, #fully_qualified_asset_path, #get_selected_class, #icon_link_to, #icon_tag, #link_to_add_fields, #link_to_remove_fields, #nav_dropdown, #number_as_cents, #number_to_dollars, #pluralize_word, #refund_header, #select_event_for_sales_search, #select_membership_type_for_sales_search, #select_pass_type_for_sales_search, #select_show_for_sales_search, #sorted_us_state_abbreviations, #sorted_us_state_names, #thanks_message, #ticket_seller_name, #time_ago_sentence, #time_zone_description, #us_states, #verb_for_save, #widget_script, #with_kit

Methods included from LinkHelper

#active?, #active_link_to, #active_section, #calendar_active_link_to, #in_section, #in_section?, #in_sub_section

Instance Method Details

#destroyObject



57
58
59
60
61
# File 'app/controllers/store/orders_controller.rb', line 57

def destroy
  current_cart.clear!
  flash[:notice] = "Your cart is empty."
  redirect_to (session[:last_event_id].blank? ? store_order_path : store_old_storefront_event_url(session[:last_event_id]))
end

#showObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/store/orders_controller.rb', line 29

def show

  @special_instructions_hash = {}
  current_cart.tickets.each do |ticket|
    event = ticket.event
    if event.show_special_instructions?
      @special_instructions_hash[event.id] = event.special_instructions_caption
    end
  end

  person = current_member.try(:person) || current_cart.applied_pass.try(:person)     
  if person.present?
    params[:first_name] ||= person.first_name
    params[:last_name]  ||= person.last_name
    params[:email]      ||= person.email
    params[:phone]      ||= person.phones.first.try(:number)

    params[:address]    ||= {}
    params[:address][:address1] = person.address.try(:address1)
    params[:address][:country] =  person.address.try(:country)
    params[:address][:city] =     person.address.try(:city)
    params[:address][:state] =    person.address.try(:state)
    params[:address][:zip] =      person.address.try(:zip)
  end
  
  @enter_code_string = (store_organization.can?(:access, :passes) ? "Use Discount or Pass Code" : "Use Discount Code")
end

#updateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/store/orders_controller.rb', line 5

def update
  handler = OrderHandler.new(current_cart, current_member)
  handler.handle_tickets(params)
  handler.handle_donation(params, @store_organization)
  handler.handle_memberships(params, current_member)
  handler.handle_passes(params)
  handler.handle_discount_or_pass_code(params)

  if handler.error.present?
    flash[:alert] = handler.error unless handler.error.blank?

    redirect_url = case params[:_source]
    when 'storefront'
      store_donate_path
    else
      store_order_path
    end

    redirect_to redirect_url
  else
    redirect_to store_order_path
  end
end