Changeset 1268

Show
Ignore:
Timestamp:
11/30/06 22:59:44 (2 years ago)
Author:
james
Message:

add color to line items in order

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • peasantonline/app/controllers/catalog_controller.rb

    r1262 r1268  
    102102                        redirect_to_index("Invalid size")  
    103103                else 
    104                         @current_item = @cart.add_product(@product, @product_detail.size
     104                        @current_item = @cart.add_product(@product, @product_detail.size, @product_detail
    105105                        @product_details = ProductDetail.find_all_by_product(params[:id]) 
    106106                        redirect_to_index unless request.xhr? 
     
    163163                #redirect_to_thanks( 
    164164                #  "Card processed successfully: #{@transaction.authorization}<p />" + " <b>Order details</b>:<br /> #{@order.first_name} #{@order.last_name}<p />" + " #{@order.address}<br />" + " #{@order.address_2}<br />" + " #{@order.city}, " + " #{@order.state}<br />" + " #{@order.zip}, " + "#{@order.country}<br />" + " #{@order.phone}<br />" + " #{@order.email}<p />" + " Comments: #{@order.comments}<p />" + " Sub-total: $#{@cart.total_price}<br />" + " Sales Tax: $#{@order.sales_tax}<br />" + " Shipping: &nbsp;$#{@order.shipping}<br />" + "------------------<br />" + " Total: &nbsp; &nbsp; $" + (@cart.total_price + @order.sales_tax + @order.shipping).to_s) 
    165  
     165            if request.host_with_port == "localhost:3000" 
     166              redirect_to_thanks("Card processed successfully: localhost") 
     167            else 
    166168              begin 
    167169                @transaction.submit 
     
    173175                redirect_to_index("Card was rejected: #{@transaction.error_message}") 
    174176              end 
     177            end 
    175178 
    176179                else  
  • peasantonline/app/models/cart.rb

    r1133 r1268  
    1111  end 
    1212 
    13   def add_product(product, size)  
     13  def add_product(product, size, product_detail)  
    1414        current_item = @items.find {|item| item.product == product && item.size == size}  
    1515    if current_item  
    1616      current_item.increment_quantity  
    1717    else  
    18       current_item = CartItem.new(product, size)  
     18      current_item = CartItem.new(product, size, product_detail)  
    1919      @items << current_item  
    2020    end  
  • peasantonline/app/models/cart_item.rb

    r1038 r1268  
    11class CartItem  
    22include Reloadable  
    3 attr_reader :product, :size, :quantity  
     3attr_reader :product, :size, :quantity, :product_detail  
    44 
    5   def initialize(product, size)  
    6     @product = product  
     5  def initialize(product, size, product_detail)  
     6    @product = product 
     7    @product_detail = product_detail  
    78    @quantity = 1  
    89    @size = size 
  • peasantonline/app/models/line_item.rb

    r1042 r1268  
    22        belongs_to :order 
    33        belongs_to :product  
     4        belongs_to :product_detail  
    45         
    56        def self.from_cart_item(cart_item)  
    67                li = self.new  
    78                li.product = cart_item.product  
     9                li.product_detail = cart_item.product_detail  
    810                li.size = cart_item.size 
    911                li.quantity = cart_item.quantity  
  • peasantonline/app/views/admin/_show_line_items.rhtml

    r1057 r1268  
    55                <th>Name</th> 
    66                <th>Size</th> 
     7                <th>Color</th> 
    78                <th>Quantity</th> 
    89                <th>Price</th> 
     
    1819                </td> 
    1920                <td> 
     21                        <%=  
     22                        if line_item.product_detail 
     23                                line_item.product_detail.color 
     24                        end 
     25                        %> 
     26                </td> 
     27                <td> 
    2028                        <%= line_item.quantity %> 
    2129                </td> 
     
    2735<% end %> 
    2836        <tr> 
    29                 <td colspan="3"> 
     37                <td colspan="4"> 
    3038                        <b>Order Total:</b> 
    3139                </td> 
  • peasantonline/db/schema.rb

    r1260 r1268  
    33# then regenerate this schema definition. 
    44 
    5 ActiveRecord::Schema.define(:version => 26) do 
     5ActiveRecord::Schema.define(:version => 27) do 
    66 
    77  create_table "categories", :force => true do |t| 
     
    2525    t.column "total_price", :integer, :default => 0, :null => false 
    2626    t.column "size", :string 
     27    t.column "product_detail_id", :integer 
    2728  end 
    2829 
    2930  add_index "line_items", ["product_id"], :name => "fk_line_item_products" 
    3031  add_index "line_items", ["order_id"], :name => "fk_line_item_orders" 
     32  add_index "line_items", ["product_detail_id"], :name => "fk_line_item_product_details" 
    3133 
    3234  create_table "orders", :force => true do |t|