corvée(formatage) màj de la configuration Mago
This commit is contained in:
parent
730184704e
commit
8e0ec560fd
34 changed files with 1108 additions and 847 deletions
|
|
@ -21,7 +21,7 @@ Timber::init();
|
|||
// Sélectionne le répertoire contenant les modèles Twig
|
||||
Timber::$dirname = ['views'];
|
||||
|
||||
$context = Timber::context();
|
||||
$context = Timber::context();
|
||||
$templates = ['email-base.twig'];
|
||||
|
||||
/** @var Order $commande La Commande issue du contexte contenu dans la variable $order. */
|
||||
|
|
@ -31,14 +31,17 @@ $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()],
|
||||
'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(),
|
||||
'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) {
|
||||
'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) {
|
||||
|
|
@ -47,31 +50,31 @@ $email = [
|
|||
|
||||
return [
|
||||
// Récupère l'Attribut d'un Produit variable ou renvoie un tableau vide
|
||||
'attribut' => $produit->is_type('variable')
|
||||
'attribut' => $produit->is_type('variable')
|
||||
? collect($produit->get_attributes())
|
||||
->mapWithKeys(static fn($_atr, $cle): array => [
|
||||
'nom' => Str::lower(wc_attribute_label($cle, $produit)),
|
||||
'nom' => Str::lower(wc_attribute_label($cle, $produit)),
|
||||
'valeur' => $produit->get_attribute($cle),
|
||||
])
|
||||
->toArray()
|
||||
: [],
|
||||
'lien' => $produit->get_permalink(),
|
||||
'nom' => $produit->get_title(),
|
||||
'lien' => $produit->get_permalink(),
|
||||
'nom' => $produit->get_title(),
|
||||
'prix_total' => $article->get_total(),
|
||||
'quantite' => $article->get_quantity(),
|
||||
'quantite' => $article->get_quantity(),
|
||||
];
|
||||
}),
|
||||
'totaux' => [
|
||||
'totaux' => [
|
||||
'sous_total_livraison' => '0' === $commande->get_shipping_total() ? 'Free' : $commande->get_shipping_total() . '€',
|
||||
'sous_total_produits' => $commande->get_subtotal() . '€',
|
||||
'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) . '€',
|
||||
'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']['livraison']['country'] = WC()->countries->countries[$commande->get_shipping_country()];
|
||||
$email['adresses']['facturation']['country'] = WC()->countries->countries[$commande->get_billing_country()];
|
||||
|
||||
$context['commande'] = $email;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue