Class: Checkout::AddressController

Inherits:
CheckoutController
  • Object
show all
Defined in:
app/controllers/gemgento/checkout/address_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



4
5
6
7
8
9
10
11
12
# File 'app/controllers/gemgento/checkout/address_controller.rb', line 4

def show
  build_billing_address if @quote.billing_address.nil?
  build_shipping_address if @quote.shipping_address.nil?

  respond_to do |format|
    format.html
    format.json { render json: { quote: @quote, totals: @quote.totals } }
  end
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/gemgento/checkout/address_controller.rb', line 14

def update
  @quote.push_addresses = true

  respond_to do |format|
    if @quote.update(quote_params)
      format.html { redirect_to (Config[:combined_shipping_payment] ? checkout_shipping_payment_path : checkout_shipping_path) }
      format.json { render json: { result: true, quote: @quote, totals: @quote.totals } }
    else
      format.html { render 'show' }
      format.json { render json: { result: false, errors: @quote.errors }, status: 422 }
    end
  end
end