Attachment File
-
Hello,
I hope plugin developers are doing great. Is there any way to send the pdf file as a attachment when any status triggered?
Thanks
Sheikh Abdullah
-
Hi @sheikhabdullah321,
Thank you for the kind words 🙂For now, it’s impossible to add files using ShopMagic. The only way to do this is to use custom PHP code and integrate with the wp_email hook https://developer.ww.wp.xz.cn/reference/hooks/wp_mail/
This example code should add file ‘path/to/the/file/to/attach.zip’ to the action email for automation with id 12.
add_action( 'shopmagic/core/action/before_execution', function ( $action, $automation, $event ) { $add_attachment = function ( $args ) { $args['attachments'][] = 'path/to/the/file/to/attach.zip'; return $args; }; if ( $automation->get_id() === 12 ) { add_filter( 'wp_mail', $add_attachment, 10, 1 ); add_action( 'shopmagic/core/action/after_execution', function ( $action, $automation, $event ) use ( $add_attachment ) { remove_action( 'wp_mail', $add_attachment, 10 ); } ); } }, 10, 3 );Have a great day! 🙂
-
This reply was modified 5 years, 1 month ago by
dyszczo.
Hi.
I´m looking for the same but I can´t get it work. Maybe the problem is the id of the automation. It´s the same as the post-id?
Also instead of ‘path/to/the/file/to/attach.zip’ I want to get an individual attachment, for example $get_order_id.pdf.-
This reply was modified 5 years ago by
befla.net.
-
This reply was modified 5 years, 1 month ago by
The topic ‘Attachment File’ is closed to new replies.