diff --git a/app/Mail/ConfirmationCommande.php b/app/Mail/ConfirmationCommande.php
index 305694c1..80981587 100644
--- a/app/Mail/ConfirmationCommande.php
+++ b/app/Mail/ConfirmationCommande.php
@@ -3,6 +3,7 @@
namespace App\Mail;
use App\Models\Core\Mail\MailTemplate;
+use App\Repositories\Shop\Orders;
use App\Repositories\Shop\Traits\MailCustomers;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -32,29 +33,44 @@ class ConfirmationCommande extends TemplateMailable
public $facturation_ville;
+ public $livraison_nom;
+
public $livraison_adresse;
+ public $livraison_adresse2;
+
public $livraison_cp;
public $livraison_ville;
+ public $facturation_nom;
+
+ public $facturation_adresse2;
+
+ public $mode_paiement;
+
protected static $templateModelClass = MailTemplate::class;
public function __construct($order)
{
- $facturation_address = $order->invoice->address;
+ $facturation_address = $order->invoice->address;
$delivery_address = $order->delivery_address;
$this->prenom = $order->customer->first_name;
$this->nom = $order->customer->last_name;
+ $this->facturation_nom = $facturation_address->name;
$this->facturation_adresse = $facturation_address->address;
+ $this->facturation_adresse2 = $facturation_address->address2;
$this->facturation_cp = $facturation_address->zipcode;
$this->facturation_ville = $facturation_address->city;
+ $this->livraison_nom = $delivery_address->name;
$this->livraison_adresse = $delivery_address->address;
+ $this->livraison_adresse2 = $delivery_address->address2;
$this->livraison_cp = $delivery_address->zipcode;
$this->livraison_ville = $delivery_address->city;
$this->societe = $order->customer->company;
$this->email = $order->customer->email;
$this->numero_commande = $order->ref;
$this->date_commande = $order->created_at;
+ $this->mode_paiement = Orders::getPaymentType($order->payment_type);
}
}
diff --git a/database/migrations/shop/2026_02_09_060000_update_mail_template_confirmation_commande.php b/database/migrations/shop/2026_02_09_060000_update_mail_template_confirmation_commande.php
new file mode 100644
index 00000000..b5a2cae8
--- /dev/null
+++ b/database/migrations/shop/2026_02_09_060000_update_mail_template_confirmation_commande.php
@@ -0,0 +1,87 @@
+transformTemplate(function ($html) {
+ // Replace hardcoded "Carte de crédit" with the template variable
+ $html = str_replace(
+ 'Carte de crédit',
+ '{{mode_paiement}}',
+ $html
+ );
+
+ // Add address2 to delivery address
+ $html = str_replace(
+ '{{livraison_adresse}}
{{livraison_cp}} {{livraison_ville}}',
+ '{{livraison_adresse}}{{#livraison_adresse2}}
{{livraison_adresse2}}{{/livraison_adresse2}}
{{livraison_cp}} {{livraison_ville}}',
+ $html
+ );
+
+ // Add address2 to billing address
+ $html = str_replace(
+ '{{facturation_adresse}}
{{facturation_cp}} {{facturation_ville}}',
+ '{{facturation_adresse}}{{#facturation_adresse2}}
{{facturation_adresse2}}{{/facturation_adresse2}}
{{facturation_cp}} {{facturation_ville}}',
+ $html
+ );
+
+ return $html;
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ $this->transformTemplate(function ($html) {
+ $html = str_replace(
+ '{{mode_paiement}}',
+ 'Carte de crédit',
+ $html
+ );
+
+ $html = str_replace(
+ '{{livraison_adresse}}{{#livraison_adresse2}}
{{livraison_adresse2}}{{/livraison_adresse2}}
{{livraison_cp}} {{livraison_ville}}',
+ '{{livraison_adresse}}
{{livraison_cp}} {{livraison_ville}}',
+ $html
+ );
+
+ $html = str_replace(
+ '{{facturation_adresse}}{{#facturation_adresse2}}
{{facturation_adresse2}}{{/facturation_adresse2}}
{{facturation_cp}} {{facturation_ville}}',
+ '{{facturation_adresse}}
{{facturation_cp}} {{facturation_ville}}',
+ $html
+ );
+
+ return $html;
+ });
+ }
+
+ private function transformTemplate(callable $transform): void
+ {
+ $template = DB::table('mail_templates')
+ ->where('mailable', 'App\\Mail\\ConfirmationCommande')
+ ->first();
+
+ if (! $template) {
+ return;
+ }
+
+ $translations = json_decode($template->html_template, true);
+
+ foreach ($translations as $lang => $html) {
+ $translations[$lang] = $transform($html);
+ }
+
+ DB::table('mail_templates')
+ ->where('id', $template->id)
+ ->update(['html_template' => json_encode($translations, JSON_UNESCAPED_UNICODE)]);
+ }
+};
diff --git a/database/migrations/shop/2026_02_09_060100_add_address_name_to_mail_template_confirmation.php b/database/migrations/shop/2026_02_09_060100_add_address_name_to_mail_template_confirmation.php
new file mode 100644
index 00000000..7f63f0b4
--- /dev/null
+++ b/database/migrations/shop/2026_02_09_060100_add_address_name_to_mail_template_confirmation.php
@@ -0,0 +1,74 @@
+transformTemplate(function ($html) {
+ // Add name before delivery address
+ $html = str_replace(
+ '{{livraison_adresse}}',
+ '{{#livraison_nom}}{{livraison_nom}}
{{/livraison_nom}}{{livraison_adresse}}',
+ $html
+ );
+
+ // Add name before billing address
+ $html = str_replace(
+ '{{facturation_adresse}}',
+ '{{#facturation_nom}}{{facturation_nom}}
{{/facturation_nom}}{{facturation_adresse}}',
+ $html
+ );
+
+ return $html;
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ $this->transformTemplate(function ($html) {
+ $html = str_replace(
+ '{{#livraison_nom}}{{livraison_nom}}
{{/livraison_nom}}{{livraison_adresse}}',
+ '{{livraison_adresse}}',
+ $html
+ );
+
+ $html = str_replace(
+ '{{#facturation_nom}}{{facturation_nom}}
{{/facturation_nom}}{{facturation_adresse}}',
+ '{{facturation_adresse}}',
+ $html
+ );
+
+ return $html;
+ });
+ }
+
+ private function transformTemplate(callable $transform): void
+ {
+ $template = DB::table('mail_templates')
+ ->where('mailable', 'App\\Mail\\ConfirmationCommande')
+ ->first();
+
+ if (! $template) {
+ return;
+ }
+
+ $translations = json_decode($template->html_template, true);
+
+ foreach ($translations as $lang => $html) {
+ $translations[$lang] = $transform($html);
+ }
+
+ DB::table('mail_templates')
+ ->where('id', $template->id)
+ ->update(['html_template' => json_encode($translations, JSON_UNESCAPED_UNICODE)]);
+ }
+};