fonc(stock) implémente gestion basique du stock
This commit is contained in:
parent
4e6f3911a6
commit
8c71a69c1b
5 changed files with 35 additions and 19 deletions
|
|
@ -124,7 +124,6 @@ services:
|
||||||
- "net.core.somaxconn=512"
|
- "net.core.somaxconn=512"
|
||||||
volumes:
|
volumes:
|
||||||
- "./containers/conf/valkey.conf:/usr/local/etc/valkey/valkey.conf:ro"
|
- "./containers/conf/valkey.conf:/usr/local/etc/valkey/valkey.conf:ro"
|
||||||
- "./containers/data/valkey:/data:rw"
|
|
||||||
wordpress:
|
wordpress:
|
||||||
container_name: "haikuatelier.fr-wordpress"
|
container_name: "haikuatelier.fr-wordpress"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
||||||
10
cspell.json
10
cspell.json
|
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
"dictionaries": ["fr-fr", "en-gb"],
|
"dictionaries": [
|
||||||
|
"fr-fr",
|
||||||
|
"en-gb"
|
||||||
|
],
|
||||||
"words": [
|
"words": [
|
||||||
"GLITCHTIP",
|
"GLITCHTIP",
|
||||||
"Vali",
|
"Vali",
|
||||||
|
|
@ -38,6 +41,9 @@
|
||||||
"wpautop",
|
"wpautop",
|
||||||
"ERRMODE",
|
"ERRMODE",
|
||||||
"laravel",
|
"laravel",
|
||||||
"multishipping"
|
"multishipping",
|
||||||
|
"multiformats",
|
||||||
|
"curryfication",
|
||||||
|
"giftcard"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@ $donnees_produit = recupere_informations_produit_page_produit(wc_get_product());
|
||||||
/** @var bool $est_variation Le Produit est-il Variable (possède-t-il des variations ?) */
|
/** @var bool $est_variation Le Produit est-il Variable (possède-t-il des variations ?) */
|
||||||
$est_produit_variable = 'variable' === $produit->get_type();
|
$est_produit_variable = 'variable' === $produit->get_type();
|
||||||
|
|
||||||
/** @var InformationsVariation[] $variations_produit Un tableau des informations d'affichage de chaque Variation du Produit */
|
/** @var array $variations_produit Un tableau des informations d'affichage de chaque Variation du Produit */
|
||||||
$variations_produit = pipe(
|
$variations_produit = pipe(
|
||||||
// Récupère les IDs des Enfants (Variations)
|
// Récupère les IDs des Enfants (Variations)
|
||||||
wc_get_product()->get_children(),
|
wc_get_product()->get_children(),
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ function genere_balise_img_multiformats($id, $lazy = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = wp_get_attachment_image_url($id, 'full');
|
$url = wp_get_attachment_image_url($id, 'full');
|
||||||
$chemin = realpath(get_attached_file($id)) ? realpath(get_attached_file($id)) : '';
|
$chemin = realpath(get_attached_file($id)) ?: realpath(get_attached_file($id));
|
||||||
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
|
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
|
||||||
$dimensions = $chemin ? getimagesize($chemin) : ['', ''];
|
$dimensions = $chemin ? getimagesize($chemin) : ['', ''];
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ function tri_variations_par_prix_descendant($a, $b) {
|
||||||
*
|
*
|
||||||
* @param WC_Product $produit
|
* @param WC_Product $produit
|
||||||
*
|
*
|
||||||
* @return InformationsProduitShop un tableau avec uniquement les informations pour la Grille de Produits
|
* @return mixed un tableau avec uniquement les informations pour la Grille de Produits
|
||||||
*/
|
*/
|
||||||
function recupere_informations_produit_shop($produit) {
|
function recupere_informations_produit_shop($produit) {
|
||||||
/** @var int $prix_maximal Le prix maximal du Produit. */
|
/** @var int $prix_maximal Le prix maximal du Produit. */
|
||||||
|
|
@ -124,9 +124,7 @@ function recupere_informations_produit_shop($produit) {
|
||||||
// Récupère le Prix de la Variation la plus chère
|
// Récupère le Prix de la Variation la plus chère
|
||||||
fn($prix) => collect($prix)->max(),
|
fn($prix) => collect($prix)->max(),
|
||||||
// Récupère le Prix pour la Variation la plus chère OU le prix du Produit simple
|
// Récupère le Prix pour la Variation la plus chère OU le prix du Produit simple
|
||||||
fn($prix_variation_maximale) => isset($prix_variation_maximale)
|
fn($prix_variation_maximale) => $prix_variation_maximale ?? $produit->get_price(),
|
||||||
? $prix_variation_maximale
|
|
||||||
: $produit->get_price(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// TEMP: Cas de la Carte Cadeau où aucun prix ne doit être affiché. Idéalement utiliser un système d'étiquettes pour ces cas là.
|
// TEMP: Cas de la Carte Cadeau où aucun prix ne doit être affiché. Idéalement utiliser un système d'étiquettes pour ces cas là.
|
||||||
|
|
@ -161,7 +159,7 @@ function recupere_informations_produit_shop($produit) {
|
||||||
/**
|
/**
|
||||||
* Retourne un tableau associatif des informations affichées sur la page Produit depuis les données brutes d'un Produit.
|
* Retourne un tableau associatif des informations affichées sur la page Produit depuis les données brutes d'un Produit.
|
||||||
*
|
*
|
||||||
* @param mixed $donnees_produit
|
* @param WC_Product $donnees_produit
|
||||||
*/
|
*/
|
||||||
function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
||||||
return [
|
return [
|
||||||
|
|
@ -197,6 +195,8 @@ function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
||||||
),
|
),
|
||||||
// Slug du Produit
|
// Slug du Produit
|
||||||
'slug' => $donnees_produit->get_slug(),
|
'slug' => $donnees_produit->get_slug(),
|
||||||
|
// Quantité de Produit en stock
|
||||||
|
'stock' => $donnees_produit->get_stock_quantity() ?? 1,
|
||||||
// Variations du Produit
|
// Variations du Produit
|
||||||
'variations_ids' => $donnees_produit->get_children(),
|
'variations_ids' => $donnees_produit->get_children(),
|
||||||
// URL du Produit
|
// URL du Produit
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="details-produit__actions">
|
<div class="details-produit__actions">
|
||||||
|
{% if produit.stock > 0 %}
|
||||||
<button
|
<button
|
||||||
class="bouton-case-pleine"
|
class="bouton-case-pleine"
|
||||||
{{ variations_produit|length > 1 ? 'disabled' : '' }}
|
{{ variations_produit|length > 1 ? 'disabled' : '' }}
|
||||||
|
|
@ -115,5 +116,15 @@
|
||||||
>
|
>
|
||||||
Add to cart
|
Add to cart
|
||||||
</button>
|
</button>
|
||||||
|
{% else %}
|
||||||
|
<button
|
||||||
|
class="bouton-case-pleine"
|
||||||
|
disabled
|
||||||
|
id="bouton-ajout-panier"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Out of stock
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue