Je suis après de l'aide, s'il vous plaît.
Je recherche un extrait de code qui joindra mes factures PDF Yith à un e-mail automatisé pour un statut de commande personnalisé que j'ai déjà créé. J'ai mis en place un statut de commande personnalisé (appelé 'facture due') qui déclenche un e-mail (appelé 'paiement en retard'), cependant, la facture pdf n'est pas jointe. L'extrait pourrait être fait pour joindre la facture pdf à tous les e-mails de statut si cela est plus facile. La facture PDF est actuellement jointe à l'e-mail de commande terminée, mais l'e-mail de statut personnalisé utilise un modèle différent (woocommerce-order-status-manager/templates/emails/customer-order-status-email.php) qui ne joint pas automatiquement le Avec fichier pdf. Des idées?
Solution du problème
add_filter('woocommerce_email_attachments', 'woocommerce_emails_attach_invoice', 10, 3);
function woocommerce_emails_attach_invoice($attachments, $email_id, $order) {
if (!is_a($order, 'WC_Order') ||!isset($email_id)) {
return $attachments;
}
if ('invoice-due' == $order->get_status()) {
$uploads = wp_upload_dir();
$invoice_path = $uploads['basedir'].'/ywpi-pdf-invoice/Invoices/';
$attachments[] = $invoice_path. 'invoice.pdf'; // Change the file location as per the requirement.
}
/*
* You can check with the desired email_id object as well ( eg:- 'new_order' )
if( 'custom_order' == $email_id ){
$attachments[] = get_template_directory(). '/invoice.pdf';
}
*
*/
return $attachments;
}
Aucun commentaire:
Enregistrer un commentaire