I''m in the process of learning rails, and am trying to implement something kind of like a shopping cart in my application. Basically, I want users to be able to kind of have a "wish list" of the products in the store. Right now, users can browse through the list of items for sale and add them to a cart. I''m stuck at the point of trying to grab the list of items from the session and save them for future viewing. I''ve looked at the shopping cart example in Agile Web Development w/ Rails, which helped get me to the point I''m currently at. However, the example of capturing an order doesn''t really fit with what I''d like to be able to do. It doesn''t seem as if I need the "order" and "line_items" models, but instead should save the list of products under a "wish list" table for the users to come back and look at. I''m thinking that it should minimally contain a column for the title of the wish list (what the user names it), plus a list of the ids of the products they have saved. Any suggestions? Do I need to have an equivalent "line_items" model, or can I just reference the ids of the products in my "wish list" table? How do I go about saving that and then displaying that in a unique url for the user to browse back to in the future? Thanks for the help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why wouldn''t you have another link/button that reads "Add to Wishlist" and when the buyer clicks on it, the item is added to the list. You will need a table for a wishlist with 2 colums: id and customer_id and a table for wishlist_items with these columns: t.column :product_id, :integer t.column :cart_id, :integer t.column :price, :float t.column :amount, :integer t.column :created_at, :datetime then your relationships should be: wishlist: has_many :cart_items has_many :products, :through => :cart_items belongs_to :custome customer: has_one: wishlist Then, you can add the items from the session to the wishlist. How to add the functionality to move the items in the cart to the wishlist, I still not sure how to do (new to rails as well). But the above works for me, so the items in the cart stay till the next time the customer logs in (with the use of an authentication system.) HTH, Elle On Nov 1, 11:06 am, dehlan <deh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m in the process of learning rails, and am trying to implement > something kind of like a shopping cart in my application. Basically, > I want users to be able to kind of have a "wish list" of the products > in the store. Right now, users can browse through the list of items > for sale and add them to a cart. I''m stuck at the point of trying to > grab the list of items from the session and save them for future > viewing. > > I''ve looked at the shopping cart example in Agile Web Development w/ > Rails, which helped get me to the point I''m currently at. However, > the example of capturing an order doesn''t really fit with what I''d > like to be able to do. It doesn''t seem as if I need the "order" and > "line_items" models, but instead should save the list of products > under a "wish list" table for the users to come back and look at. I''m > thinking that it should minimally contain a column for the title of > the wish list (what the user names it), plus a list of the ids of the > products they have saved. Any suggestions? Do I need to have an > equivalent "line_items" model, or can I just reference the ids of the > products in my "wish list" table? How do I go about saving that and > then displaying that in a unique url for the user to browse back to in > the future? Thanks for the help.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Check out RailsCart... http://groups.google.com/group/railscart?lnk=li http://code.google.com/p/railscart/ http://railscart.org/ HTH - Dave Porter On Nov 1, 9:06 am, dehlan <deh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m in the process of learning rails, and am trying to implement > something kind of like a shopping cart in my application. Basically, > I want users to be able to kind of have a "wish list" of the products > in the store. Right now, users can browse through the list of items > for sale and add them to a cart. I''m stuck at the point of trying to > grab the list of items from the session and save them for future > viewing. > > I''ve looked at the shopping cart example in Agile Web Development w/ > Rails, which helped get me to the point I''m currently at. However, > the example of capturing an order doesn''t really fit with what I''d > like to be able to do. It doesn''t seem as if I need the "order" and > "line_items" models, but instead should save the list of products > under a "wish list" table for the users to come back and look at. I''m > thinking that it should minimally contain a column for the title of > the wish list (what the user names it), plus a list of the ids of the > products they have saved. Any suggestions? Do I need to have an > equivalent "line_items" model, or can I just reference the ids of the > products in my "wish list" table? How do I go about saving that and > then displaying that in a unique url for the user to browse back to in > the future? Thanks for the help.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the input. What I don''t understand is why there needs to be another wishlist_items table. Wouldn''t that mean that with every add to your wishlist there is a new row in a separate table that just points products to a wishlist? I just see the wishlist_items table growing to be very large. Is there a way to direct a product directly into a wishlist without having to have a middle step? So basically, is there a way to do it without having to have a wishlist_items point a product id to a wishlist id -- could the wishlist just contain the list of products itself without an in between? It would only really need a user_id and a product_list, avoiding any redundant entries (like price, quantity, etc which is done at checkout anyways). Thanks again. On Nov 1, 2:05 am, elle <wazne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Why wouldn''t you have another link/button that reads "Add to Wishlist" > and when the buyer clicks on it, the item is added to the list. > You will need a table for a wishlist with 2 colums: id and customer_i > and a table for wishlist_items with these columns: > t.column :product_id, :integer > t.column :cart_id, :integer > t.column :price, :float > t.column :amount, :integer > t.column :created_at, :datetime > > then your relationships should be: > wishlist: > has_many :cart_items > has_many :products, :through => :cart_items > belongs_to :custome > > customer: > has_one: wishlist > > Then, you can add the items from the session to the wishlist. > > How to add the functionality to move the items in the cart to the > wishlist, I still not sure how to do (new to rails as well). > But the above works for me, so the items in the cart stay till the > next time the customer logs in (with the use of an authentication > system.) > > HTH, > Elle > > On Nov 1, 11:06 am,dehlan<deh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m in the process of learning rails, and am trying to implement > > something kind of like a shopping cart in my application. Basically, > > I want users to be able to kind of have a "wish list" of the products > > in the store. Right now, users can browse through the list of items > > for sale and add them to a cart. I''m stuck at the point of trying to > > grab the list of items from the session and save them for future > > viewing. > > > I''ve looked at the shopping cart example in Agile Web Development w/ > > Rails, which helped get me to the point I''m currently at. However, > > the example of capturing an order doesn''t really fit with what I''d > > like to be able to do. It doesn''t seem as if I need the "order" and > > "line_items" models, but instead should save the list of products > > under a "wish list" table for the users to come back and look at. I''m > > thinking that it should minimally contain a column for the title of > > the wish list (what the user names it), plus a list of the ids of the > > products they have saved. Any suggestions? Do I need to have an > > equivalent "line_items" model, or can I just reference the ids of the > > products in my "wish list" table? How do I go about saving that and > > then displaying that in a unique url for the user to browse back to in > > the future? Thanks for the help.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---