1

I'm building a shop with many promotions. Some articles in the shopping cart have a linked promotion I want to show in the shopping cart summary, before the order completion.

It's a shop without any visible prices. The total amount of the order is calculated on the servers. There is nothing to worry about that.

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

3 Answers 3

1

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
  • 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, 2013 at 2:34
0

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.

0

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.

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