I want to modify and update the items in the Depot - "display_cart". Since the cart is in a session, its a little hard to get at the data. I just want to create a way to change quantities, prices and recalculate. Has someone done this, and could you point me to the right direction. Thanks Chas -- Posted via http://www.ruby-forum.com/.
On 8/15/06, chas conquest <chas@valley.net> wrote:> I want to modify and update the items in the Depot - "display_cart". > Since the cart is in a session, its a little hard to get at the data. > > I just want to create a way to change quantities, prices and > recalculate. > > Has someone done this, and could you point me to the right direction. > > Thanks > > Chas > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Why is it hard to modify the cart if it''s in a session? Are you trying to modify it from a model or a controller? Joe
At this point, I''ve made an edit view for the cart, which just
duplicates a ''display_cart''.
They went into the cart from the cart.rb
def add_product(product)
item = @items.find {|i| i.product_id == product.id}
if item
item.quantity += 1
else
item = LineItem.for_product(product)
@items << item
end
@total_price += product.rate
end
But i can''t figure out how to access individual parts of the item.
Joe Van Dyk wrote:> On 8/15/06, chas conquest <chas@valley.net> wrote:
>> Chas
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>> _______________________________________________
>> Rails mailing list
>> Rails@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
> Why is it hard to modify the cart if it''s in a session?
>
> Are you trying to modify it from a model or a controller?
>
> Joe
--
Posted via http://www.ruby-forum.com/.
OMG did I hit the motherlode.....with <%= session.inspect %> at the
bottom of a template.
Now if there were a way to parse it....Whew...
##0, "quantity"=>2, "product_id"=>1,
"unit_price"=>69.0},
@new_record=true, @product=#"/images/wireless.jpg",
"company"=>"Audio
Technica", "name"=>"Wireless Mic",
"category"=>"wMic",
"serial"=>"140001",
"price"=>"599", "rate"=>"69",
"id"=>"1",
"model"=>"ATW1-1127"}>>, #0,
"quantity"=>2, "product_id"=>16,
"unit_price"=>89.0}, @new_record=true,
@product=#"/images/mackie808.jpg",
"company"=>"Mackie", "name"=>"Mackie
808S", "category"=>"pMixer",
"serial"=>"808S", "price"=>"899",
"rate"=>"89", "id"=>"16",
"model"=>"808S"}>>], @total_price=316.0>,
"flash"=>{}}, @dbprot=[#, @hash={:cart=>#0,
"quantity"=>2,
"product_id"=>1, "unit_price"=>69.0},
@new_record=true,
@product=#"/images/wireless.jpg", "company"=>"Audio
Technica",
"name"=>"Wireless Mic",
"category"=>"wMic",
"serial"=>"140001",
"price"=>"599", "rate"=>"69",
"id"=>"1",
"model"=>"ATW1-1127"}>>, #0,
"quantity"=>2, "product_id"=>16,
"unit_price"=>89.0}, @new_record=true,
@product=#"/images/mackie808.jpg",
"company"=>"Mackie", "name"=>"Mackie
808S", "category"=>"pMixer",
"serial"=>"808S", "price"=>"899",
"rate"=>"89", "id"=>"16",
"model"=>"808S"}>>], @total_price=316.0>,
"flash"=>{}}>], @dbman=#, @hash={:cart=>#0,
"quantity"=>2,
"product_id"=>1, "unit_price"=>69.0},
@new_record=true,
@product=#"/images/wireless.jpg", "company"=>"Audio
Technica",
"name"=>"Wireless Mic",
"category"=>"wMic",
"serial"=>"140001",
"price"=>"599", "rate"=>"69",
"id"=>"1",
"model"=>"ATW1-1127"}>>, #0,
"quantity"=>2, "product_id"=>16,
"unit_price"=>89.0}, @new_record=true,
@product=#"/images/mackie808.jpg",
"company"=>"Mackie", "name"=>"Mackie
808S", "category"=>"pMixer",
"serial"=>"808S", "price"=>"899",
"rate"=>"89", "id"=>"16",
"model"=>"808S"}>>], @total_price=316.0>,
"flash"=>{}}>, @new_session=false,
@session_id="39450964efb89fc11fb29555a3bf6d76">
--
Posted via http://www.ruby-forum.com/.