I'd be tempted to have an order_items table that is not ruled by habtm. Then 
you can add columns for product_id, quantity, price_charged, tax, dispatched 
etc.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 9 Aug 2010, at 17:27, Felix wrote:

> Hi, I was wondering if anyone can help with a problem I'm having.
> 
> I'm building a simple shopping cart system for which I have two
> objects
> 
> 1. Product (stores product details - name, cost, SKU, etc.)
> 
> 2. Order (Stores order details - customer address, shipping type,
> etc.)
> 
> In the database these are joined using the table, orders_products.
> 
> Cake correctly recognises the HABTM relationship between the two, so
> far so good.
> 
> What I'm now stuck at is how to incorporate a quantity variable.
> 
> Each product in an order must have a quantity but I don't know where
> to put it,
> 
> I don't think it belongs in the products table or the order table, so
> the only place I can think of is in the join table (orders_products).
> 
> If I add this field in how would I then set or read its value, seeing
> as it has no model I don;t know how to address it.
> 
> The join table does show up when baking so I could add one, but I
> don't know if this would mess up the HABTM between the product and
> order models, and if it does what relationships I need to define in
> the relevant models to resolve such issues.
> 
> I may of course be missing something or asking a very stupid question,
> in which case sorry but could you point out my idiocy!
> 
> Thanks, Felix
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to