2024-08-09
This commit is contained in:
parent
afed5b0470
commit
bd804e6083
21 changed files with 402 additions and 36 deletions
|
|
@ -9,26 +9,25 @@ use Timber\Timber;
|
|||
|
||||
// Contexte et modèles
|
||||
$contexte = Timber::context();
|
||||
$modeles = ["shop.twig"];
|
||||
$modeles = ["boutique.twig"];
|
||||
|
||||
// Récupère les Produits
|
||||
$recupere_informations_produit = fn($produit) => [
|
||||
"id" => $produit->id,
|
||||
"illustration" => [
|
||||
"image" => wp_get_attachment_image(get_post_thumbnail_id($produit->id), "full"),
|
||||
],
|
||||
"nom" => $produit->name,
|
||||
"prix" => $produit->price,
|
||||
"slug" => $produit->slug,
|
||||
"premiere_variation_image" => wp_get_attachment_image(
|
||||
$attachment_id = $produit->get_available_variations()[0]["image_id"],
|
||||
$size = "large",
|
||||
$attr = ["loading" => false],
|
||||
"id" => $produit->get_id(),
|
||||
"nom" => $produit->get_name(),
|
||||
"prix" => $produit->get_price(),
|
||||
"slug" => $produit->get_slug(),
|
||||
"premiere_photo_gauche" => wp_get_attachment_image(
|
||||
get_post_meta($post_id = $produit->get_id(), $key = "_photos_colonne_gauche|||0|value")[0],
|
||||
"full",
|
||||
false,
|
||||
["loading" => false],
|
||||
),
|
||||
"deuxieme_variation_image" => wp_get_attachment_image(
|
||||
$attachment_id = $produit->get_available_variations()[1]["image_id"],
|
||||
$size = "large",
|
||||
$attr = ["loading" => false],
|
||||
"premiere_photo_droite" => wp_get_attachment_image(
|
||||
get_post_meta($post_id = $produit->get_id(), $key = "_photos_colonne_droite|||0|value")[0],
|
||||
"full",
|
||||
false,
|
||||
["loading" => false],
|
||||
),
|
||||
"url" => $produit->get_permalink(),
|
||||
];
|
||||
|
|
@ -40,10 +39,10 @@ $informations_produits = wc_get_products([
|
|||
$produits = array_map($callback = $recupere_informations_produit, $array = $informations_produits);
|
||||
$contexte["produits"] = $produits;
|
||||
|
||||
echo "<pre>";
|
||||
// echo "<pre>";
|
||||
// print_r($informations_produits);
|
||||
// print_r($produits);
|
||||
echo "</pre>";
|
||||
// echo "</pre>";
|
||||
|
||||
// Rendu
|
||||
Timber::render($filenames = $modeles, $data = $contexte);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue