Custom Function delay on updating sales order

Custom Function delay on updating sales order

Hi all,

I've written a Deluge script that updates the shipping charge depending on the sub total on a sales order. The script only works after repeated page refreshing (whether this to do with delays on the back end or something else i don't know)

Ideally i would want the deluge script to happen in real time on the order. Is this possible as the current method is not really acceptable.