Re-add order writing to onbeforecallback