Do not remove/add fees on every order save event
-
Hi there,
seems like since 2.10 your plugin removes (and readds) (gateway) fees on every
save_post
event. That logic is triggered by checkout-fees-for-woocommerce/includes/class-alg-wc-order-fees.php. Please don’t do it. That’s a very bad practice and causes a lot of incompatibilities with other plugins – updating fees should only happen in case of a recalculation event, e.g.woocommerce_order_before_calculate_taxes
(and/or in case the order payment gateway changes). Furthermore instead of removing the fee items altogether (as inAlg_WC_Order_Fees::remove_fees()
), retrieve/search for the existing fee order item if existent. If it does not yet exist, add a new item.And please use Woo hooks, e.g.
woocommerce_order_after_calculate_totals
to do so in a standard-compliant way instead of using thesave_post
event. There is no need to trigger additional order save events.Best
- The topic ‘Do not remove/add fees on every order save event’ is closed to new replies.