- First commit to issue fork.
- πΊπΈUnited States MegaphoneJon
[I apparently just made a commit via a comment? Someone please remove that.]
I'm a little late to this party, but if anyone else has this issue, here's some code I wrote to remove a line item from an order. Use this with the "After saving a new commerce line item" event. I wish you could prevent it being added on presave but the requisite data isn't available at that time.
function wrltweaks_rules_action_info() { return [ 'wrltweaks_remove_line_item_from_order' => [ 'label' => t('Remove item from order'), 'group' => t('Commerce Line Item'), 'parameter' => [ 'commerce_line_item' => [ 'type' => 'commerce_line_item', 'label' => t('Line item'), ], 'commerce_order' => [ 'type' => 'commerce_order', 'label' => t('Order'), ], ], ], ]; } function wrltweaks_remove_line_item_from_order($lineItem, $order) { $lineItemId = $lineItem->line_item_id; commerce_cart_order_product_line_item_delete($order, $lineItemId, TRUE); }