wip avec résolution de conflits

This commit is contained in:
gcch 2026-02-27 14:38:50 +01:00
commit ef19ba2b72
208 changed files with 178625 additions and 192002 deletions

View file

@ -13,7 +13,7 @@ use Illuminate\Support\Str;
use Timber\Timber;
if (!defined('ABSPATH')) {
exit;
exit();
}
// Initialise Timber
@ -31,49 +31,44 @@ $commande = $order;
$date = new Carbon($commande->get_date_created());
$email = [
'adresses' => [
'facturation' => $commande->get_address('billing'),
'livraison' => $commande->get_address('shipping'),
],
'commande' => ['date' => $date->toDateString(), 'id' => $commande->get_id()],
'livraison' => [
'methode' => $commande->get_shipping_method(),
'numero_suivi' => $commande->get_meta('tracking_number'),
],
'paiement' => ['methode' => ''],
'produits' => collect($commande->get_items())->map(static function (WC_Order_Item_Product $article) {
$produit = $article->get_product();
'adresses' => ['facturation' => $commande->get_address('billing'), 'livraison' => $commande->get_address('shipping')],
'commande' => ['date' => $date->toDateString(), 'id' => $commande->get_id()],
'livraison' => [
'methode' => $commande->get_shipping_method(),
'numero_suivi' => $commande->get_meta('tracking_number')
],
'paiement' => ['methode' => ''],
'produits' => collect($commande->get_items())->map(static function (WC_Order_Item_Product $article) {
$produit = $article->get_product();
if (is_bool($produit) || $produit === null) {
return [];
}
if (is_bool($produit) || $produit === null) {
return [];
}
return [
// Récupère l'Attribut d'un Produit variable ou renvoie un tableau vide
'attribut' => $produit->is_type('variable')
? collect($produit->get_attributes())
->mapWithKeys(static fn($_atr, $cle): array => [
'nom' => Str::lower(wc_attribute_label($cle, $produit)),
'valeur' => $produit->get_attribute($cle),
])
->toArray()
: [],
'lien' => $produit->get_permalink(),
'nom' => $produit->get_title(),
'prix_total' => $article->get_total(),
'quantite' => $article->get_quantity(),
];
}),
'totaux' => [
'sous_total_livraison' => '0' === $commande->get_shipping_total()
? 'Free'
: $commande->get_shipping_total() . '€',
'sous_total_produits' => $commande->get_subtotal() . '€',
'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) . '€',
],
return [
// Récupère l'Attribut d'un Produit variable ou renvoie un tableau vide
'attribut' => $produit->is_type('variable')
? collect($produit->get_attributes())
->mapWithKeys(static fn($_atr, $cle): array => [
'nom' => Str::lower(wc_attribute_label($cle, $produit)),
'valeur' => $produit->get_attribute($cle)
])
->toArray()
: [],
'lien' => $produit->get_permalink(),
'nom' => $produit->get_title(),
'prix_total' => $article->get_total(),
'quantite' => $article->get_quantity()
];
}),
'totaux' => [
'sous_total_livraison' => '0' === $commande->get_shipping_total() ? 'Free' : $commande->get_shipping_total() . '€',
'sous_total_produits' => $commande->get_subtotal() . '€',
'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) . '€'
]
];
// Transforme les codes de pays en noms de pays
$email['adresses']['livraison']['country'] = WC()->countries->countries[$commande->get_shipping_country()];
@ -82,6 +77,6 @@ $email['adresses']['facturation']['country'] = WC()->countries->countries[$comma
$contexte['commande'] = $email;
// Rendu
Timber::render(
filenames: $modeles,
data: $contexte,
filenames: $modeles,
data: $contexte
);