Zend certified PHP/Magento developer

Correct way to remove and add product to order on sales_order_place_before event

I’m trying to use the sales_order_place_before event to remove or add products to the order only after successful payment but facing a few different problems.

There are a few different solutions I could find, but every time I’m there is a different issue:

  • Products I’m adding are not correctly deducted from the stock
  • Cannot force that newly added product price is 0 when I’m adding more than one. Only the last one got 0.
  • The new product must be listed separately on the order/invoice if this product already exists on the order.

I also need to remove some of the existing products from the order simultaneously and replace them with different ones.

As this will not affect the order total, I think that order recalculation is unnecessary.

Unfortunately, I’m confused if I should still make those changes on the quote or have already edited the order, so I would appreciate it if someone could tell me the correct way to do it.