I'm using onPopulateLineItem in my plugin to dynamically set the price of products added to the cart based on user input on the front-end -
$lineItem = $event->params['lineItem'];
$size = craft()->request->getPost('size');
$colour = craft()->request->getPost('colour');
$finish = craft()->request->getPost('finish');
$options = array(
'size' => $size,
'colour' => $colour,
'finish' => $finish
);
$lineItem->options = $options;
$lineItem->price = $dynamicPrice;
This is working fine, however, if the same product item is added to the cart but with different options (and therefor a different price) the existing line item is overwritten with the new values/price.
Is there a way I can create a new line item each time, rather than overwrite the existing one? Do I need to use a different event or create some kind of custom controller?
Thanks!