// This could happen if there is no contribution or we are in one of many
// weird and wonderful flows. This is scary code. Keep adding tests.
- if (!empty($params['line_item']) && empty($ids['contribution'])) {
+ if (!empty($params['line_item']) && empty($ids['contribution']) && empty($params['contribution_id'])) {
foreach ($params['line_item'] as $priceSetId => $lineItems) {
foreach ($lineItems as $lineIndex => $lineItem) {