You can buy there, there is a special passport office to the left of the entrance. If you go out the back of it there is a entrance to the park usually with no line(or short), even when the regular gates are really busy. Only probelm is the staff there tend to be chatty so takes as long as going other way.
Just looked online and they are doing buy one year get 2nd at half off, sometimes offers like that ar not available in the passport office but this deal doesn't say that so it could be.
Any offers just before you fly I would buy online to be sure but I believe SW AP's are activated on purchase now, not at the gate as in the past so don't buy til last minute.