1
Answers
Vote up!
0
Vote down!

How to get custom product line item text field value?

Hello everyone,
by using commerce customisable products I created a custom product line type to which I added a text field (Machine name field_license_details). By following this excellent video tutorial
http://commerceguys.com/blog/commerce-module-tuesday-commerce-customizab...
I was able to create a node/page which include the text field I mentioned before. However, what I find impossible to do, is to get the value that the user entered to that field. For example, when the user has entered something in the text field and clicks the add to cart button, I want the text he typed, to be 'placed' to a variable so i can do whatever i like with it, for example display it back to the user or write it down to a file etc. I understand that in order to achieve that I would need to write my own module , but I am not sure which hook I should implement in order to do that and how to extract the string.
As you probably already understood by the nature of the question ,I am just getting started on drupal, so any suggestions would be more than welcome.
Thanks in advance
PS I am using drupal 7.22 (the latest stable version and I have installed the drupal commerce module, the commerce file and commerce customisable products.

Asked by: Comm-nooby
on July 8, 2013

Comments

The answer depends on what you want to do with that field's value. At the end of the linked video, Randy shows how to add the value to the shopping cart view, so that's one way to "use" the value.

- Favio Manriquez on July 9, 2013

1 Answer

Vote up!
0
Vote down!

The value that the customer puts there will end up in a field on the line item. This data can be used in various places through the user interface (i.e. Views, Rules, Tokens) depending on what you're doing. If you're trying to show that value in the shopping cart block, then you'll need to edit the View that creates the block and add the field to be displayed there.

It probably doesn't bear to reproduce tutorials existing elsewhere in this answer, though, so I'd advise you to search on Views or Rules tutorials to learn how to use this field data in different parts of the site.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Jul 9, 2013