Automatically attach Invoice PDF to confirmation receipt based on the gl...

...obal setting
Why we need this logic to append PDF?  Can't we avoid foreach iteration?