Discussions

Mutiple product types / line items > one product display?

I'm in a situation where I've spent a massive amount of time theming a product display node type which has a referenced product type and a product line item. Now I'm going to add a donation line item type into the mix.

Is there a way for me to avoid having to make a new donation display node type? The donations should look exactly the same except that you can type in a variable amount in the add to cart form.

Currently it seems to me it is the add to cart form on the node type that determines which line item type is added to the cart. This feels a bit backwards to me. Why is it not the referenced product type which determines the line item?

Posted: Nov 7, 2012

Comments

TwiiK on November 8, 2012

Seems the only thing I had to do was for the products that I wanted to be donations I changed $type to my donation line item in commerce_cart_field_formatter_view(). Had to override the hook in my own module to avoid hacking commerce, but it works so well and was so easy it just makes me wonder even more why you have to "hard code" the line item in your product reference field display settings.

The referenced product type should control what line item is added to the cart imo.

amberau on March 24, 2013

I wholeheartedly agree. I can't help but wonder about the architecture of Drupal Commerce sometimes. For a system intended to be flexible it can be ridiculously un-flexible.