rundum.digital | blog - So fügst du Anhänge bei WooCommerce-Bestellungen hinzu

So fügst du Anhänge bei WooCommerce-Bestellungen hinzu

Jing Zhou / 30. August 2017 / , , , , / WooCommerce / 6 Kommentare

Für den Betrieb eines Online-Shops ist es wichtig, dass die Käufer über das Widerrufsrecht belehrt werden und diese Information müssen auch auf einem dauerhaften Datenträger wie z.B. Email-Anhang zur Verfügung gestellt werden.

Mit diesem Code in der functions.php, kannst du Anhänge per Email mit der Bestellbestätigung mitsenden – natürlich ohne Einsatz vom Plugin.

Passe ggf. noch den Pfad und die Dateinamen an.

In meinem Bespiel liegen die Dateien AGB.pdf und Widerrufsbelehrung.pdf im wp-content/themes/theme-ordner/woocommerce/attached-files/

 

 

  1. von Björn am 22. März 2018 20:57 Uhr

    Wow! Not a single comment? I can’t believe it.
    Thanks, Jing, for your code, it really saved me some time. And it’s doing its job, I just tested.
    Again, thank you very much, highly appreciated!
    -Björn

    Antworten

    • von Jing Zhou am 23. März 2018 09:25 Uhr

      Thank you for your comment 🙂

      Antworten

  2. von Björn am 01. Mai 2018 01:33 Uhr

    Hey Jing,

    am using this snippet for a while now and it is working just flawless. 🙂
    Because I’m currently working on saving my changes from being overwritten by updates, I would like to attach the files from a source outside of my theme folder. I assume get_template_directory () is not the right command to do that, because in my tests attachments haven’t been send.
    I’m using ‚theme-customisation‘ as a plugin in which you can store your php, js and css snippets. It is located in the usual /wp-content/plugins directoy. Within this folder I created an email folder and put my attachments in there. The path I inserted is the following:
    ‚/plugins/theme-customisation-master/custom/emails/attached-files/Widerrufsrecht.pdf‘

    Do you have an idea on how to pick up these files and attach them to my mails again using your script?

    Thank you, best regards
    -Björn

    Antworten

  3. von Björn am 03. Mai 2018 17:22 Uhr

    Hey again,

    I found the solution in the meantime. For all your visitors who are facing similar problems:
    If you are also using a plugin from which you can add php/js/css code and you want to store your email attachments within this plugin to save them from being overwritten by your next theme update, replace the get_template function and change the path to your attachment like this:
    $agb_pdf_path = plugin_dir_path(__FILE__) . ‚emails/attached-files/AGB.pdf‘;
    My attachment is stored in wp-content/plugins/MyPlugin/emails/attached-files/

    Best regards,

    -Björn

    Antworten

    • von Jing Zhou am 03. Mai 2018 20:27 Uhr

      Hi Björn,

      I am very sorry, that I did not replied to your post.
      It’s very busy with daily business.

      You can also upload the file to WordPress Media and using the URL to that file, which is in the upload folder.

      Cheers,
      Jing

      Antworten

  4. von Björn am 04. Mai 2018 13:17 Uhr

    Hi Jing,

    no worries, I was glad to be able to figure it out. Upload folder is a good idea, too. Wondering why I didn’t come up with that. 🙂

    Have a great weekend,

    -Björn

    Antworten

Was sagst du dazu?