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
|
|
@ -6,6 +6,8 @@ use Carbon_Fields\Carbon_Fields;
|
|||
use HaikuAtelier\StarterSite;
|
||||
use Timber\Timber;
|
||||
|
||||
use function wp_enqueue_script_module;
|
||||
|
||||
// Récupère les dépendances Composer
|
||||
require_once __DIR__ . '../../../../../vendor/autoload.php';
|
||||
require_once __DIR__ . '/src/StarterSite.php';
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use function Crell\fp\pipe;
|
|||
require_once __DIR__ . '/src/inc/TraitementInformations.php';
|
||||
|
||||
/** @var string $url_accueil L'URL de la page d'Accueil. */
|
||||
$url_accueil = get_page_link(get_page_by_path('home')->ID);
|
||||
$url_accueil = get_page_link(get_page_by_path('home')?->ID);
|
||||
|
||||
/** @var string $session_id L'ID de la Session Stripe liée à la Commande. */
|
||||
$session_id = $_GET['session_id'];
|
||||
|
|
@ -72,7 +72,7 @@ try {
|
|||
|
||||
// Récupère le nom et la valeur de l'attribut du Produit
|
||||
$attribut = $produit->is_type('variable')
|
||||
? collect($produit->get_attributes())->mapWithKeys(function ($atr, $cle) use ($produit_commande) {
|
||||
? collect($produit->get_attributes())->mapWithKeys(function ($_atr, $cle) use ($produit_commande) {
|
||||
$nom_attribut = wc_attribute_label($cle, $produit_commande->get_product());
|
||||
$valeur_attribut = $produit_commande->get_product()->get_attribute($cle);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,25 @@ use Roots\WPConfig\Config;
|
|||
use Timber\Site;
|
||||
use Timber\URLHelper;
|
||||
|
||||
use function add_action;
|
||||
use function add_theme_support;
|
||||
use function array_map;
|
||||
use function base64_encode;
|
||||
use function Crell\fp\pipe;
|
||||
use function Env\env;
|
||||
use function esc_url;
|
||||
use function get_categories;
|
||||
use function get_option;
|
||||
use function get_page_by_path;
|
||||
use function get_page_link;
|
||||
use function get_privacy_policy_url;
|
||||
use function get_theme_mod;
|
||||
use function get_theme_mods;
|
||||
use function preg_match;
|
||||
use function WC;
|
||||
use function wp_create_nonce;
|
||||
use function wp_get_attachment_image_src;
|
||||
use function wpautop;
|
||||
|
||||
class StarterSite extends Site {
|
||||
public function __construct() {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ function enregistre_controle_personnalise_tinymce(): void {
|
|||
/**
|
||||
* Enqueue our scripts and styles.
|
||||
*/
|
||||
#[\Override()]
|
||||
public function enqueue(): void {
|
||||
wp_enqueue_script(
|
||||
handle: 'controle-personnalise-tinymce',
|
||||
|
|
@ -39,6 +40,7 @@ function enregistre_controle_personnalise_tinymce(): void {
|
|||
/**
|
||||
* Pass our TinyMCE toolbar string to JavaScript.
|
||||
*/
|
||||
#[\Override()]
|
||||
public function to_json(): void {
|
||||
parent::to_json();
|
||||
|
||||
|
|
@ -58,6 +60,7 @@ function enregistre_controle_personnalise_tinymce(): void {
|
|||
/**
|
||||
* Render the control in the customizer.
|
||||
*/
|
||||
#[\Override()]
|
||||
public function render_content() { ?>
|
||||
<div class="tinymce-control">
|
||||
<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ function retire_merdes_wc() {
|
|||
*
|
||||
* @return WP_REST_Response
|
||||
*/
|
||||
function genere_balises_img_dans_produit_dans_reponse_rest($response, $product) {
|
||||
function genere_balises_img_dans_produit_dans_reponse_rest($response, $_product) {
|
||||
// Vérifie que la Réponse a des données
|
||||
if (empty($response->data)) {
|
||||
return $response;
|
||||
|
|
@ -180,13 +180,12 @@ add_filter('woocommerce_rest_prepare_product_object', 'genere_balises_img_dans_p
|
|||
/**
|
||||
* TODO.
|
||||
*
|
||||
* @param WP_REST_Respone $$reponse
|
||||
* @param WC_Data $produit
|
||||
* @param mixed $reponse
|
||||
* @param WP_REST_Response $reponse
|
||||
* @param WC_Data $_produit
|
||||
*
|
||||
* @return WP_REST_Response
|
||||
*/
|
||||
function genere_prix_maximal_produit_variable_dans_reponse_rest($reponse, $produit) {
|
||||
function genere_prix_maximal_produit_variable_dans_reponse_rest($reponse, $_produit) {
|
||||
// Vérifie que la Réponse a des données
|
||||
if (empty($reponse->data)) {
|
||||
return $reponse;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ $email = [
|
|||
'commande' => ['date' => $date->toDateString(), 'id' => $commande->get_id()],
|
||||
'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')
|
||||
'attribut' => $article->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()
|
||||
: [],
|
||||
|
|
@ -65,10 +65,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
|
||||
|
|
@ -76,6 +76,7 @@ $email['adresses']['livraison']['country'] = WC()->countries->countries[$command
|
|||
$email['adresses']['facturation']['country'] = WC()->countries->countries[$commande->get_billing_country()];
|
||||
|
||||
$contexte['commande'] = $email;
|
||||
|
||||
// Rendu
|
||||
Timber::render(
|
||||
filenames: $modeles,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue