fix: order confirmation email shows wrong payment method and incomplete address
The email template had "Carte de crédit" hardcoded regardless of the
actual payment method. The address blocks were also missing the
``address2`` and ``name`` fields.
- Add ``mode_paiement``, ``livraison_nom``, ``facturation_nom``,
``livraison_adresse2``, ``facturation_adresse2`` to
``ConfirmationCommande`` Mailable
- Migration to replace hardcoded payment label with
``{{mode_paiement}}`` and add ``address2`` fields in DB template
- Migration to add ``name`` fields before each address block
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user