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

redben’s picture

Linking to drupalcommerce.org for reference
http://www.drupalcommerce.org/node/112

rszrama’s picture

Issue tags: -products +cart

Actually, this should be a concern of the Cart module, not the product reference module.

rszrama’s picture

Component: Code » Cart
pieterdc’s picture

Version: » 7.x-1.x-dev

Isn't this one included in latest dev already?
As far as I know; it is.

rszrama’s picture

Status: Active » Needs work

It'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.

rszrama’s picture

Assigned: Unassigned » rszrama
Issue tags: -cart

Alright, 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...

rszrama’s picture

Screenshots of my example, using a T-shirt product type with a Size field containing Small, Medium, Large, and X-Large options.

The basic form:
Only local images are allowed.

After selecting a Size option that results in multiple matches:
Only local images are allowed.

The referenced products on that form:
Only local images are allowed.

The product type configuration showing the Size field:
Only local images are allowed.

redben’s picture

Great work Ryan !

rszrama’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.