Tags/topics: 
2
Answers
Vote up!
1
Vote down!

Proper way to display custom line item fields on checkout form

Hi!

Is there any proper way to display custom line item fields on checkout form?

I know that I can add each custom field one by one into views but it's complicated when I have few line items with dozen conditional fields and you need always to remember about it.

I found out that I can add to checkout view "Rendered Commerce Line item", formater: "render complete entity" and choose necessary fields by adding custom view mode by hook_entity_info_alter. That's great with one little problem. It's always rendering number before my fields (it's line item id?).

http://screenshooter.net/100249231/qyrlcyx

Is there any way to get rid of that number (maybe altering some hook?) or other way to list out all line item fields?

Lukasz Zmudziak
Asked by: Lukasz Zmudziak
on October 9, 2014

2 Answers

Vote up!
1
Vote down!

Hi Lukasz,

You are almost there. An easy way to get rid of the number is to override the default template which is entity.tpl.php. Just copy that entity into your theme calling it something like commerce-line-item.tpl.php (you can use devel_themer to get some template suggestions). Then just edit your template to take out the title as that is what is displaying the number.

Lance

Answer by: Lance Holland
Posted: Oct 16, 2014
Vote up!
0
Vote down!

Unfortunately, forms (line item add to cart forms) within forms (cart forms that let you modify quantity) is a non-starter.

Additionally, there is no core way of handling editing a line item field that is customer facing. But take heart! If you are using vanilla Commerce (not kickstart 2) then there's a patch that enables this:

https://www.drupal.org/node/1211278

Also, there's a sandbox that claims to do this as well: https://www.drupal.org/sandbox/jasen/1858212

Good luck! Maybe you can join the ranks of that patch issue that is 3 years old trying to bring this feature home.

Josh

Josh Miller
Answer by: Josh Miller
Posted: Oct 9, 2014

Comments

But that is not the problem. I looking for a way to just display all line item fields on checkout view (without ability to edit them).

I figured out that I can use views field "Rendered Commerce Line item" but it also prints out line item id (title?). Check out screenshot: http://screenshooter.net/100249231/qyrlcyx

- Lukasz Zmudziak on October 9, 2014