It does not seem to be possible presently to have a customer be able to enter custom text to go on a product, like a custom message for a shirt/mug/card/etc. I can add a text field to a product, but that seems only to be defined at the time of the product's creation, and is never "exposed" to the customer for editing as they are adding it to their cart.

Ubercart supported this and it was a very useful bit of functionality.

Comments

rszrama’s picture

Title: Customer-provided text for products » Support customizable products via the Add to Cart form
Status: Active » Postponed

The problem here is that in Drupal Commerce, the Add to Cart form adds a specific product from the back end to the cart via a product line item. Therefore, you can't customize random attributes and associate them with the product in the cart. However, it does seem likely we could include some way for line item fields to show up in the Add to Cart form... this would lead to us needing to support multiple product line item types, though, and I'm not sure if we want to go there or not. It might mean we just need some sort of sub-entity that gets attached to a line item, using some model like the Micro module is exploring.

For 1.0, though, customizable products will remain off the roadmap. I'll make sure to add this feature to the potential list of 2.0 features to pursue. It's something we've thought about, we just haven't written any proposals / issues for the features yet.

arcadian83’s picture

Thanks for your reply. I was not aware of Micro, and will look into it. :)

arcadian83’s picture

After a little playing around with Micro and Drupal Commerce, I'd say that Micro has some maturing to do (still in 1.x-dev), and Drupal Commerce currently does not integrate with it.

(Just so people reading this don't get the idea that it's currently a viable solution based on my last post.)

mikejoconnor’s picture

Could this be handled via contrib already ?

I.e. it seems like a contrib module could create a custom add to cart widget, which would allow a user to customize the current product, either via a on the fly, check box based product kit. or possibly via on the fly product creation (add a name for engraving).

Either way, it almost seems like this could be done already, in the contrib space, but I could be wrong.

hunziker’s picture

I create a new project. This project tries to accomplish this feature. You can find it here:
Commerce Option

At the moment you need to apply the patch contained in the module repository. I have add an issue to bring this change into the core of commerce.

rszrama’s picture

(Just a note to say I committed hunziker's patch.)

Summit’s picture

Hi, link to Commerce Option is "page not found". Where is this module please?
greetings,
Martijn

rszrama’s picture

Component: Product » Cart
Assigned: Unassigned » rszrama
Status: Postponed » Needs work
Issue tags: +rcblocker

It's been updated to a full project: http://drupal.org/project/commerce_option

Also, I should add that I just put support for including line item fields on the Add to Cart form. I forgot this issue existed, but I hadn't pushed yet... so I'll update my commit message to point here and outline the new code / changes I'm working on right now:

  1. My most recent commit embeds line item fields in the Add to Cart form based on the type of $line_item passed into the form. Other recent changes updated this form to receive a line item parameter instead of a variety of options parameters. The form is on its way to functioning as an edit form as well as an add form. Only line item fields marked for inclusion on the form will appear there, which currently will only be custom fields that you add to your product line item type and whose inclusion checkbox you click.
  2. I need to update commerce_cart_product_add() to receive a line item object, too, and to compare field values when deciding whether or not to combine line items. I'll also add an option to the Add to Cart form display formatter that lets you bypass combining line items if you want regardless of field data.
  3. I'm about to support multiple product line item types. When I do this, I'll update the Add to Cart display formatter to let you specify which product line item type to use for the form. This will let you use different types of line items / Add to Cart forms for different types of products.
  4. I'll follow that up with the necessary changes to make the form work as an edit form.

When that's all done (this evening), I'll consider this issue fixed. : )

rszrama’s picture

Damien Tournoud’s picture

Shaping up (4):

4a. Before calling the add to cart form, the formatter will have to check if there is a "combinable" line item. If there is, it should load it and pass it to the add to cart form
4b. As a consequence, the combination logic currently in commerce_cart_product_add() needs to be abstracted into an API function
4c. The same option of the add to cart formatter mentioned in 2b needs to control whether or not we do 4a in the first place

This will also solve the long standing issue that the quantity field is always 1 regardless if you already have the product in your cart or not. Sweet.

rszrama’s picture

Committed http://drupalcode.org/project/commerce.git/commitdiff/27beea5 to fix item 3. Specifically I had to add a new filter to support multiple product line item types in our various Cart Views, add support and documentation for the 'product' property of line item types, and add API functions / make API adjustments to support multiple line item types. This commit also fixes some failing tests b/c the Base test class wasn't updated for the new parameters of commerce_cart_product_add() when I made the commit for item 1.

rszrama’s picture

Just committed the follow-up to add options to the display formatter settings supporting selecting from available product line item types. I also changed the line item configuration callback to receive the $line_item_type array as a parameter. This means if you want to quickly create a new product line item type, you just have to set its 'base' => 'commerce_product_line_item' to reuse all the standard product line item type callbacks.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/7355dcc

rszrama’s picture

Status: Needs work » Fixed
Issue tags: -rcblocker

As an RC blocker, I think the necessary work has been completed. I've opened a follow-up issue to address item #4 as it will require no change other than to the form submit handler and display formatter.

See: #1211278: Allow commerce_cart_add_to_cart_form() to edit line items

Status: Fixed » Closed (fixed)

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