This one's gonna be a doozy. Basically, we need to turn the product reference data into an add to cart form that functions like Ubercart's current add to cart form... except each option is going to add a specific product to the shopping cart. I won't explain it much further than this at the moment, and we'll see how it develops:
Product reference fields can reference single or multiple products. This Field will come with an "Add to Cart form" formatter that generates an Add to Cart form based on the selected products. When multiple products are referenced, the Add to Cart form will automatically create the appropriate form elements needed for the user to choose one of the products to add to the cart.
Comments
Comment #1
redben commentedLinking to drupalcommerce.org for reference
http://www.drupalcommerce.org/node/112
Comment #2
rszrama commentedActually, this should be a concern of the Cart module, not the product reference module.
Comment #3
rszrama commentedComment #4
pieterdcIsn't this one included in latest dev already?
As far as I know; it is.
Comment #5
rszrama commentedIt's roughly working; perhaps I should update the status and explain.
What needs work is the current formatter simply lists all the referenced products in a select list. It doesn't do any "smart" joining based on Fields attached to the products to present Ubercart-style attributes on the add to cart form. That part remains to be done, though I believe we simplified what use cases we needed to accommodate for launch in the notes from our Paris sprint.
Basically, I want the add to cart formatter to look at the types of the referenced products. If the products are of the same type, we can assume they'll have the same fields. If any of the fields are required, only allow a single value, and possess a fixed number of options (i.e. via a select list or radio list), then we should figure out those field values for the referenced products and populate select lists so the user is actually choosing the option for the product they want to purchase. This won't work for a set of products that use the same option, though, so we'll have to sort that out... and it also won't automatically work for products of different types that possess the same fields (though I'd like it to).
As a fallback measure, the form can always be displayed as it currently is - but we need to at least get some price information in that select list so it's apparent different options can have different prices. And I'd want to come up with a sensible label perhaps for the select list... or allow a "multi-select" where instead of a single select list you get a list of Qty. fields where you can purchase any number of each referenced product at once.
Comment #6
rszrama commentedAlright, mammoth commit here progressing this. I basically implemented everything I mentioned above, but I added in a product selection widget in the event that a set of attributes matches more than one product. It's airtight and makes me giddy.
Still need to do work in conjunction with the Product Reference module so the Add to Cart form updates the product field information displayed on the page with values from the selected product.
Commit: https://github.com/rszrama/drupalcommerce/commit/d4f16b48d301775121113c6...
Comment #7
rszrama commentedScreenshots of my example, using a T-shirt product type with a Size field containing Small, Medium, Large, and X-Large options.
The basic form:

After selecting a Size option that results in multiple matches:

The referenced products on that form:

The product type configuration showing the Size field:

Comment #8
redben commentedGreat work Ryan !
Comment #9
rszrama commentedUpdates are working with the product fields on the page. Yay. : )
My three relevant commits from today:
https://github.com/rszrama/drupalcommerce/commit/f08c544f00dd4cd53eb7c70...
https://github.com/rszrama/drupalcommerce/commit/88b2050b6220ae1d02d0d0f...
https://github.com/rszrama/drupalcommerce/commit/b55fbc4068ccf33ef978ea8...