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
77 lines
2.1 KiB
PHP
77 lines
2.1 KiB
PHP
<?php
|
|
|
|
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;
|
|
use Spatie\MailTemplates\TemplateMailable;
|
|
|
|
class ConfirmationCommande extends TemplateMailable
|
|
{
|
|
use MailCustomers, Queueable, SerializesModels;
|
|
|
|
public $email;
|
|
|
|
public $nom;
|
|
|
|
public $prenom;
|
|
|
|
public $societe;
|
|
|
|
public $subject;
|
|
|
|
public $numero_commande;
|
|
|
|
public $date_commande;
|
|
|
|
public $facturation_adresse;
|
|
|
|
public $facturation_cp;
|
|
|
|
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;
|
|
$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);
|
|
}
|
|
}
|