Class: Workarea::Storefront::Checkout::GiftCardsController

Inherits:
CheckoutsController
  • Object
show all
Defined in:
app/controllers/workarea/storefront/checkout/gift_cards_controller.rb

Instance Method Summary collapse

Instance Method Details

#addObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/workarea/storefront/checkout/gift_cards_controller.rb', line 5

def add
  step = Workarea::Checkout::Steps::GiftCard.new(current_checkout)

  if step.update(params)
    flash[:success] = t('workarea.storefront.flash_messages.gift_card_added')
    redirect_to checkout_payment_path
  else
    @step = Storefront::Checkout::PaymentViewModel.new(
      step,
      view_model_options
    )

    flash[:error] = t('workarea.storefront.flash_messages.gift_card_error')
    render :payment
  end
end

#removeObject



22
23
24
25
26
27
28
# File 'app/controllers/workarea/storefront/checkout/gift_cards_controller.rb', line 22

def remove
  step = Workarea::Checkout::Steps::GiftCard.new(current_checkout)
  step.remove(params[:gift_card_id])

  flash[:success] = t('workarea.storefront.flash_messages.gift_card_removed')
  redirect_to checkout_payment_path
end