Google Analytics – Does GA's enhanced e-commerce use the transaction ID to consolidate transactions?

I am looking for improved e-commerce with Google Analytics and there are predefined events for common scenarios such as purchases, etc.

How does Google Analytics handle two purchases sent with it? Transaction's ID? Will it count as two separate purchases? Or will it only record the first event and count the subsequent ones with the same event? Transaction's ID as a duplicate?

I'm asking because I'm not sure how to track "unique" events like this and log in. If I implement these events, then that is going to be a much of conditional code in my application that looks like this:

yes ($ _SESSION['order_was_placed']) {
echo "gtag (& # 39 ;, & # 39; purchase & # 39 ;, {...})";

Does it seem like it's going to be a nightmare to add to the templates on my website?