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"
|
||||
volumes:
|
||||
- "./containers/conf/valkey.conf:/usr/local/etc/valkey/valkey.conf:ro"
|
||||
- "./containers/data/valkey:/data:rw"
|
||||
wordpress:
|
||||
container_name: "haikuatelier.fr-wordpress"
|
||||
depends_on:
|
||||
|
|
|
|||
12
cspell.json
12
cspell.json
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"dictionaries": ["fr-fr", "en-gb"],
|
||||
"dictionaries": [
|
||||
"fr-fr",
|
||||
"en-gb"
|
||||
],
|
||||
"words": [
|
||||
"GLITCHTIP",
|
||||
"Vali",
|
||||
|
|
@ -38,6 +41,9 @@
|
|||
"wpautop",
|
||||
"ERRMODE",
|
||||
"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 ?) */
|
||||
$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(
|
||||
// Récupère les IDs des Enfants (Variations)
|
||||
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');
|
||||
$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);
|
||||
$dimensions = $chemin ? getimagesize($chemin) : ['', ''];
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ function tri_variations_par_prix_descendant($a, $b) {
|
|||
*
|
||||
* @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) {
|
||||
/** @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
|
||||
fn($prix) => collect($prix)->max(),
|
||||
// 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)
|
||||
? $prix_variation_maximale
|
||||
: $produit->get_price(),
|
||||
fn($prix_variation_maximale) => $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à.
|
||||
|
|
@ -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.
|
||||
*
|
||||
* @param mixed $donnees_produit
|
||||
* @param WC_Product $donnees_produit
|
||||
*/
|
||||
function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
||||
return [
|
||||
|
|
@ -197,6 +195,8 @@ function recupere_informations_produit_page_produit($donnees_produit): mixed {
|
|||
),
|
||||
// Slug du Produit
|
||||
'slug' => $donnees_produit->get_slug(),
|
||||
// Quantité de Produit en stock
|
||||
'stock' => $donnees_produit->get_stock_quantity() ?? 1,
|
||||
// Variations du Produit
|
||||
'variations_ids' => $donnees_produit->get_children(),
|
||||
// URL du Produit
|
||||
|
|
|
|||
|
|
@ -107,13 +107,24 @@
|
|||
</div>
|
||||
|
||||
<div class="details-produit__actions">
|
||||
<button
|
||||
class="bouton-case-pleine"
|
||||
{{ variations_produit|length > 1 ? 'disabled' : '' }}
|
||||
id="bouton-ajout-panier"
|
||||
type="button"
|
||||
>
|
||||
Add to cart
|
||||
</button>
|
||||
{% if produit.stock > 0 %}
|
||||
<button
|
||||
class="bouton-case-pleine"
|
||||
{{ variations_produit|length > 1 ? 'disabled' : '' }}
|
||||
id="bouton-ajout-panier"
|
||||
type="button"
|
||||
>
|
||||
Add to cart
|
||||
</button>
|
||||
{% else %}
|
||||
<button
|
||||
class="bouton-case-pleine"
|
||||
disabled
|
||||
id="bouton-ajout-panier"
|
||||
type="button"
|
||||
>
|
||||
Out of stock
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</aside>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue