In Woocommerce, I was looking to get order ID just before payment, when the order is created. I found this answer below:
Get the order ID in checkout page before payment process
What I need is to pass in tracking script the transaction ID (as specified on the script) and I should be able to track in clickwork7 dashboard:
<script type="text/javascript" src="https://clickwork7secure.com/p.ashx?
o=45875&e=12995&f=js&t=TRANSACTION_ID"></script>
But the transaction ID seems to be empty after a purchase in Paypal for example, so may be I should pass the order ID instead.
The Order received page seems to be the right place, but for cancelled or failed orders, Where and how to embed this script?
Any help is appreciated.
Updated: It is possible to use many different hooks for that:
wp_head
wp_footer
woocommerce_thankyou
You can try to use the:
$order_key = get_post_meta( $order_id, '_order_key', true );
$transaction_id = get_post_meta( $order_id, '_transaction_id', true );
1) Using
woocommerce_thankyou
hook: The simpler way as the Order Id is a hook argument:Code goes in function.php file of your active child theme (or active theme). It should work.
2) Using
wp_head
hook:Code goes in function.php file of your active child theme (or active theme). It should work.
Similar answers: