I'm building a webshop with a lot of promotions in. And some articles in the shopping cart, have a linked promotion. And I want to show this promotion in the shopping cart summary (before the order completion).

Is there a way to change the title of the product in the shopping cart summary?

It's a shop without any visible prices. The total amount of the order is calculated on the servers... (it's a complicated proces). So there is nothing to worry about that...

But how can I display the pink text in a proper way? Would it be best to get this data from the database and place it as a field in a table (since the shopping cart summary is a view)? Or what other options do I have?

enter image description here


Please note that items in the cart are not products, but line_items (referenced to the product of course)

I think this hook can fit your needs, but I haven't tested it (in my situation, I added the line item directly using custom functions in my module)

  • 1
    You are right. But the title for line items goes from product title. You should edit it earlier. The product title creates in time the product created. It can be generated automatically (if 'Auto generate the product title' option is turned on on the product display content type editing form), can be overrided (in hook_commerce_cart_product_add()), can be filled in manually. Nov 9 '13 at 2:34

There are sevetal methods for this:

  1. You can set the product title as you want on /admin/commerce/products page. Edit product and set your title.

  2. You can set the product title in a moment you add it. To view this field the option 'Auto generate the product title' should be turned off on product display content type settings.

  3. You can use the hook_commerce_cart_product_add() to set the product title automatically and (for example) depending on product type.


The answer depends on the nature of your 'linked promotions'. It might be that you should add an entity reference field to your line item type, then add the field to the shopping cart view. If your promotions are based on tagging products with taxonomy terms, it's as simple as adding the field to the cart view.

Or, as @Strae said, you could alter the line item's title via hook_commerce_cart_product_add. Yet another way would be to alter the line item's 'label' via Rules and show that in the cart instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.