Why is my code in the msGetOrder snippet executed several times (3 times)?

Good morning, experts of Modx, I have a question of this nature, modifying the functionality of ordering, namely integration with Frontpad.

I add my code to the msGetOrder snippet which is executed after pressing the button to place an order, but my code is executed several times (3 times), as a result of which 3 identical orders arrive at once in Frontpad.

if (!empty($toPlaceholder)) {
    $modx->setPlaceholder($toPlaceholder, $output);
else {
	// Код находится в данном месте 		
    return $output;

I can not figure out why this is happening, tell me the reason.


It’s almost impossible to know without seeing all the code and looking at where you put your code. It’s possible that you put your code inside a loop or that the snippet is executed by a plugin that responds to more than one event (or it’s a plugin not a snippet), or that the snippet tag is in a template that is used by several steps in the ordering process (so it executes once for each step).