Set a lineItem option from within a plugin?
I'm guessing you're doing this in a plugin and not the front end using an input for a reason?

I struggled with this recently and had luck using the following:

// Get the line item from the event
$item = $event-&gt;params['lineItem'];

// We get all the options from the post request
$options = craft()-&gt;request-&gt;getPost('options', []);

// Add the new value
$options['optionKey'] = 'newValue';

// Save the options to the line item
$item-&gt;options = $options;


If somebody can suggest an improvement to this I'd be grateful.