2026-04-03
This commit is contained in:
parent
15371d2469
commit
5f835ca4e6
45 changed files with 819 additions and 626 deletions
|
|
@ -20,9 +20,9 @@ if (!defined('ABSPATH')) {
|
|||
Timber::init();
|
||||
// Sélectionne le répertoire contenant les modèles Twig
|
||||
Timber::$dirname = ['views'];
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ['email-base.twig'];
|
||||
|
||||
$context = Timber::context();
|
||||
$templates = ['email-base.twig'];
|
||||
|
||||
/** @var Order $commande La Commande issue du contexte contenu dans la variable $order. */
|
||||
$commande = $order;
|
||||
|
|
@ -35,7 +35,7 @@ $email = [
|
|||
'commande' => ['date' => $date->toDateString(), 'id' => $commande->get_id()],
|
||||
'livraison' => [
|
||||
'methode' => $commande->get_shipping_method(),
|
||||
'numero_suivi' => $commande->get_meta('tracking_number')
|
||||
'numero_suivi' => $commande->get_meta('tracking_number'),
|
||||
],
|
||||
'paiement' => ['methode' => ''],
|
||||
'produits' => collect($commande->get_items())->map(static function (WC_Order_Item_Product $article) {
|
||||
|
|
@ -51,14 +51,14 @@ $email = [
|
|||
? collect($produit->get_attributes())
|
||||
->mapWithKeys(static fn($_atr, $cle): array => [
|
||||
'nom' => Str::lower(wc_attribute_label($cle, $produit)),
|
||||
'valeur' => $produit->get_attribute($cle)
|
||||
'valeur' => $produit->get_attribute($cle),
|
||||
])
|
||||
->toArray()
|
||||
: [],
|
||||
'lien' => $produit->get_permalink(),
|
||||
'nom' => $produit->get_title(),
|
||||
'prix_total' => $article->get_total(),
|
||||
'quantite' => $article->get_quantity()
|
||||
'quantite' => $article->get_quantity(),
|
||||
];
|
||||
}),
|
||||
'totaux' => [
|
||||
|
|
@ -67,16 +67,16 @@ $email = [
|
|||
'sous_total_reduction' => '0.00' === $commande->get_discount_total()
|
||||
? '0'
|
||||
: Number::format((float) $commande->get_discount_total(), maxPrecision: 2) . '€',
|
||||
'total' => Number::format((float) $commande->get_total(), maxPrecision: 2) . '€'
|
||||
]
|
||||
'total' => Number::format((float) $commande->get_total(), maxPrecision: 2) . '€',
|
||||
],
|
||||
];
|
||||
// Transforme les codes de pays en noms de pays
|
||||
$email['adresses']['livraison']['country'] = WC()->countries->countries[$commande->get_shipping_country()];
|
||||
$email['adresses']['facturation']['country'] = WC()->countries->countries[$commande->get_billing_country()];
|
||||
|
||||
$contexte['commande'] = $email;
|
||||
$context['commande'] = $email;
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
data: $contexte
|
||||
filenames: $templates,
|
||||
data: $context,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue