Skip to content

Instantly share code, notes, and snippets.

@sipple
Created August 18, 2010 20:22
Show Gist options
  • Save sipple/536053 to your computer and use it in GitHub Desktop.
Save sipple/536053 to your computer and use it in GitHub Desktop.
#Set Primary address a.k.a Billing Address [ugh]
class BillingInformationController < ApplicationController
no_login_required
before_filter :must_be_at_least_an_authenticated_user
before_filter :cart_should_not_be_empty
radiant_layout 'normal'
helper :users, :orders
include SslRequirement
ssl_required :billing_information
def billing_information
session_key = the_current_key
@addresses = Address.find_all session_key
primary_address = @addresses.empty? ? Address.default_address : @addresses.find {|address| address.primary}
@billing_address = Address.new params[:address]
@billing_address.save_as_primary session_key unless primary_address.same_as? @billing_address
@order = current_order
@order.gift_cards.each {|gc| gc.load_shipping_address(session_key)}
@shipping_methods = ShippingMethod.find_all session_key
p @shipping_methods
@countries = Country.find_all
render :partial => 'orders/shipping_details'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment