fix: corrige certains soucis avec les emails
This commit is contained in:
parent
71c35a497f
commit
c6664a7597
16 changed files with 179 additions and 121 deletions
|
|
@ -42,19 +42,19 @@ $email = [
|
|||
],
|
||||
'paiement' => ['methode' => ''],
|
||||
'produits' => collect($commande->get_items())->map(function (WC_Order_Item_Product $article) {
|
||||
/** @var WC_Product_Simple|WC_Product_Variable $produit */
|
||||
$produit = wc_get_product($article['product_id']);
|
||||
$produit = $article->get_product();
|
||||
|
||||
/** @var WC_Product_Simple|WC_Product_Variation $produit_article */
|
||||
$produit_article = $article->get_product();
|
||||
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(fn($atr, $cle) => [
|
||||
'nom' => Str::lower(wc_attribute_label($cle, $produit_article)),
|
||||
'valeur' => $produit_article->get_attribute($cle),
|
||||
->mapWithKeys(fn($_atr, $cle) => [
|
||||
'nom' => Str::lower(wc_attribute_label($cle, $produit)),
|
||||
'valeur' => $produit->get_attribute($cle),
|
||||
])
|
||||
->toArray()
|
||||
: [],
|
||||
|
|
@ -69,10 +69,10 @@ $email = [
|
|||
? 'Free'
|
||||
: $commande->get_shipping_total() . '€',
|
||||
'sous_total_produits' => $commande->get_subtotal() . '€',
|
||||
'sous_total_reduction' => '0.00' === $commande->get_discount_total
|
||||
'sous_total_reduction' => '0.00' === $commande->get_discount_total()
|
||||
? '0'
|
||||
: Number::format($commande->get_discount_total(), maxPrecision: 2) . '€',
|
||||
'total' => Number::format($commande->get_total(), maxPrecision: 2) . '€',
|
||||
: 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue