woocommerce_email_attachments

FILTER woocommerce\includes\emails\class-wc-email.php (ligne 648) github
Get email attachments.
traduction française
Obtenir des pièces jointes aux courriers électroniques.

Paramètres

Entrée :
array(
Sortie :
@return array

Utilisation

Ajouter des pièces jointes aux emails

Joindre des fichiers PDF ou autres aux emails de commande

order-flow ui
// Ajouter pièces jointes aux emails
add_filter('woocommerce_email_attachments', 'ajouter_pieces_jointes_email', 10, 3);

function ajouter_pieces_jointes_email($attachments, $email_id, $order) {
    // Joindre CGV pour nouvelles commandes
    if ($email_id === 'customer_processing_order') {
        $cgv_path = get_template_directory() . '/documents/cgv.pdf';
        if (file_exists($cgv_path)) {
            $attachments[] = $cgv_path;
        }
    }
    
    // Joindre facture pour commandes complétées
    if ($email_id === 'customer_completed_order' && $order) {
        $invoice_path = '/path/to/invoices/invoice-' . $order->get_id() . '.pdf';
        if (file_exists($invoice_path)) {
            $attachments[] = $invoice_path;
        }
    }
    
    return $attachments;
}

Actualités

Chargement des actualités...