0

I am using $order->add_order_note( $note ); in my payment gateway plugin to send custom private order note to new orders.

But its sending customer order notes again when i refresh/reload thank you (order received) page

is there any conditional tag or function that i can use to send custom order notes only once for new orders.

means check if its a newly created order (once)

1 Answers1

0

You could probably include a hidden field with a random key or GUID that it's generated server side and at the beginning of your process and carried through all steps. At the Thank You page and together with your processing, you can save the key/GUID with the order.

This way, you can check if the key/GUID was already processed on a prior order and thus conclude it's a refresh or if the user went back and forth with the browser. You can also clear history for the browser to disallow going back, but checking the key would allow you to prevent the order being processed twice.

Related question and answer.

Luc
  • 320
  • 4
  • 11
  • Sorry but I did not understood, I am an amature developer, Please tell me something like a conditional tag that i can use to check if its a new order (just created) once. to send order note only once, not again and again on order received page refresh/reload. – formalxcom Oct 26 '19 at 04:09
  • Sorry I wasn't clearer, but I don't know woocommerce so I tried to give you a general answer. I'm not sure there's a tag or simple configuration that you can use. Do you have a database, apart from sending orders to woocommerce? I mean, do you store data on your site? – Luc Oct 26 '19 at 04:18
  • no sir. i dont have. i just started with woocommerce – formalxcom Oct 26 '19 at 05:30