Class: Workarea::Storefront::CartsController

Inherits:
ApplicationController show all
Includes:
CheckInventory, CheckPricingOverride
Defined in:
app/controllers/workarea/storefront/carts_controller.rb

Instance Method Summary collapse

Methods included from CheckPricingOverride

#check_pricing_override

Methods included from CheckInventory

#check_inventory

Methods inherited from ApplicationController

#current_layout, #current_user_info, #health_check, #layout_content

Methods included from OrderLookup

#lookup_order, #lookup_order=

Methods included from CurrentCheckout

#clear_current_order, #completed_order, #completed_order=, #current_checkout, #current_order, #current_order=, #current_shipping, #current_shippings, #logout

Instance Method Details

#add_promo_codeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/workarea/storefront/carts_controller.rb', line 16

def add_promo_code
  if Pricing.valid_promo_code?(params[:promo_code], current_checkout.email)
    current_order.add_promo_code(params[:promo_code])
    flash[:success] = t(
      'workarea.storefront.flash_messages.promo_code_added',
      promo_code: params[:promo_code]
    )

    redirect_to promo_code_destination
  else
    flash[:error] = t('workarea.storefront.flash_messages.promo_code_error')
    redirect_to "#{promo_code_destination}?#{params[:promo_code].to_query(:promo_code)}"
  end
end

#resumeObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/workarea/storefront/carts_controller.rb', line 31

def resume
  if order = Order.find_by(token: params[:token]) rescue nil
    self.current_order = order
    flash[:success] = t('workarea.storefront.flash_messages.order_resumed')
  else
    flash[:error] = t('workarea.storefront.flash_messages.order_not_resumed')
  end

  redirect_to cart_path
end

#showObject



11
12
13
14
# File 'app/controllers/workarea/storefront/carts_controller.rb', line 11

def show
  Pricing.perform(current_order, current_shippings)
  @cart = CartViewModel.new(current_order, view_model_options)
end