Obvious stuff first:
Email code including AMPScript is interpreted top to bottom.
So at the end of your code, the last variable assignment is the result.
Plain text is interpreted after HTML.
The "top to bottom" rule thus is valid across the different elements:
AMPscript processes functions in this order:
- HTML Body
- Text Body
- Subject Line
- Any preheader values reside at the beginning of the body and process accordingly.
https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/orderOfOperations.html
The default behavior is that the plain text version is auto-generated. This auto-generated version repeats every bit of code from HTML, including AMPScript, which would prevent your problem (but can create others) as the vars would be reassigned in plain text again.
So normally, plain text is copy of HTML.
html:
If you now switch to plain text, and once you start manually editing the plain text version to differ from the HTML (ask yourself why), this message appears when you start:
...only then can you start writing your plain text version.
plain:
From that point on, the system doesn't copy anything you do in HTML into plain text, and you have to set your variables again in the plain text, or the last variable assignment from HTML stays throughout the entire plain text version - which is what you observed. All links were the last variable from HTML.
Solution:
So - 99% of usecases, you want to just "restore text from HTML" in the plain text version and never think about it again.
after pressing "restore" you can see that AMPScript is automatically replicated with the html content in plain text version, so that your problem would not occur because the var assignment is repeated:
...and you are back at the default behavior again.
===
IF you really really are in the 1% of usecases that truly need different HTML and plain text versions - think again about how important your special text version is - THEN you have to manually replicate the AMPscript in your altered plain text version and maintain all AMPscript twice.
to be clear: Including some (any) text version is good practice for e.g. deliverability. So definitely include one. But having a manually crafted, custom tailored text version is in my experience almost never worth the effort.