Class: Checkout::ShippingController

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

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
# File 'app/controllers/gemgento/checkout/shipping_controller.rb', line 7

def show
  initialize_shipping_variables

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

#updateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/gemgento/checkout/shipping_controller.rb', line 16

def update
  @quote.shipping_amount = @quote.get_shipping_amount(quote_params[:shipping_method], JSON.parse(cookies[:shipping_methods], symbolize_names: true))
  @quote.push_shipping_method = true

  respond_to do |format|
    if @quote.update(quote_params)
      format.html { redirect_to checkout_payment_path }
      format.json { render json: { result: true, quote: @quote, totals: @quote.totals } }
    else
      initialize_shipping_variables
      format.html { render action: :show }
      format.json { render json: { result: false, errors: @quote.errors }, status: 422 }
    end
  end
end