0

I would like to update the title of a order item before it's put in the cart to add some extra dynamic info for the user. I tried this but nothing changes.

In the onCartEntityAdd function:

$item = $event->getOrderItem();

// Some code to check that its the item I wanted then:    

$newTitle = $item->getTitle() . ' - some extra info';
$item->setTitle($newTitle);

setTitle call does not seem to do anything, the title in the cart is still just the product name. The getTitle() call works though.

Thanks for any info.

1 Answer 1

0

The problem is probably that you don't save the order item after updating the title.

Add $item->save(); at the end of your code and it should work.

2
  • Thank you for the reply. I do have the save(). I neglected to put it in the example above, still does not work.
    – user96682
    Oct 14, 2019 at 15:02
  • UPDATE: for anyone who cares. The order item title is being updated. My assumption that the cart is using that for title is wrong. The title in the cart is coming from somewhere else, I just have to find where.
    – user96682
    Oct 14, 2019 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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