Phenomene Posted December 23, 2018 Share Posted December 23, 2018 (edited) Bonjour, Je souhaiterais ne pas afficher les quantités disponibles de mes produits, seulement informer mes clients que le produit est en stock. En cherchant j'ai trouvé deux solutions(ci- dessous). Cela n'a pas fonctionner. Quelqu'un aurait une idée. Merci Voici le texte product.tpl de mon thème {/if} {if ($display_qties == 1 && !$PS_CATALOG_MODE && $PS_STOCK_MANAGEMENT && $product->available_for_order)} <!-- number of item in stock --> <p id="pQuantityAvailable"{if $product->quantity <= 0}style="display: none;"{/if}> <span id="quantityAvailable">{$product->quantity|intval}</span> <span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='Item'} </span> <span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='Items'} </span> </p> {/if} <!-- availability or doesntExist --> <p id="availability_statut"{if !$PS_STOCK_MANAGEMENT || ($product->quantity <= 0 && !$product->available_later && $allow_oosp) || ($product->quantity > 0 && !$product->available_now) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}> {*<span id="availability_label">{l s='Availability:'}</span>*} <span id="availability_value" class="label{if $product->quantity <= 0 && !$allow_oosp} label-danger{elseif $product->quantity <= 0} label-warning{else} label-success{/if}">{if $product->quantity <= 0}{if $PS_STOCK_MANAGEMENT && $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{elseif $PS_STOCK_MANAGEMENT}{$product->available_now}{/if}</span> </p> {if $PS_STOCK_MANAGEMENT} {if !$product->is_virtual}{hook h="displayProductDeliveryTime" product=$product}{/if} <p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties || $product->quantity <= 0) || $allow_oosp || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}</p> {/if} <p id="availability_date"{if ($product->quantity > 0) || !$product->available_for_order || $PS_CATALOG_MODE || !isset($product->available_date) || $product->available_date < $smarty.now|date_format:'%Y-%m-%d'} style="display: none;"{/if}> <span id="availability_date_label">{l s='Availability date:'}</span> <span id="availability_date_value">{if Validate::isDate($product->available_date)}{dateFormat date=$product->available_date full=false}{/if}</span> </p> <!-- Out of stock hook --> <div id="oosHook"{if $product->quantity > 0} style="display: none;"{/if}> {$HOOK_PRODUCT_OOS} </div> {if isset($HOOK_EXTRA_RIGHT) && $HOOK_EXTRA_RIGHT}{$HOOK_EXTRA_RIGHT}{/if} {if !$content_only} <!-- usefull links--> <ul id="usefull_link_block" class="clearfix no-print"> Masquer les quantités disponibles à l’aide de Smarty Cette méthode est donc ma préférée, car elle est la plus fiable. Ce n’est pas parce que visuellement vous masquez un élément que celui-ci n’existe plus, et c’est bien la le souci avec les CSS et le référencement naturel d’un site Prestashop. Ainsi, nous allons travailler sur le fichier product.tpl, se trouvant à la racine de votre thème. Celui-ci affiche n’importe quel produit, et nous allons donc désactiver une bonne fois pour toutes les quantités affichées pour les produits. Comme nous l’avons détecté plus haut, product-availability est l’élément à retirer. Rechercher donc dans le fichier product.tpl ceci : id= »product-availability » Une fois l’élément trouvé, mettez-le en commentaires Smarty comme ceci : 1 2 3 4 5 6 7 8 9 10 {* {if ($display_qties == 1 && !$PS_CATALOG_MODE && $PS_STOCK_MANAGEMENT && $product->available_for_order)} <!-- number of item in stock --> <div id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}> <span id="quantityAvailable">{$product->quantity|intval}</span> <span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='Item'}</span> <span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='Items'}</span> </div> {/if} *} Vous noterez les conditions smarty affichées, mais surtout retenez bien le mode opératoire pour retirer du code HTML mais en le conservant dans votre fichier, avec {* pour ouvrir un commentaire, et *} pour le refermer. Les quantités disponibles sont à présent complètement masquées sur votre site, et même en cherchant à inspecter le code vous ne pourrez les trouver, ce qui demeure bien plus propre et sécurisé. Notez que c’est à l’intérieur de cette syntaxe que vous pouvez tout simplement avoir des conditions afin de n’afficher les quantités disponibles que si et seulement si celles-ci atteignent un seuil critique, plutôt intéressant ! Alors tu édites le fichier product.tpl, et tu supprime (ou tu mets en commentaire grace à <!-- et --> ) les lignes suivantes <!-- number of item in stock --> quantity == 0} style="display:none;"{/if}> {$product->quantity|intval} quantity > 1} style="display:none;"{/if} id="quantityAvailableTxt">{l s='item in stock'} quantity == 1} style="display:none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'} Tu remplaces par <!-- number of item in stock quantity == 0} style="display:none;"{/if}> {$product->quantity|intval} quantity > 1} style="display:none;"{/if} id="quantityAvailableTxt">{l s='item in stock'} quantity == 1} style="display:none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'} --> Ensuite pour mettre juste en stock je sais pas j'ai tester des trucs mais ça fonctionne pas. Edited March 20 by Phenomene (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted December 23, 2018 Share Posted December 23, 2018 Euh.... 1 Link to comment Share on other sites More sharing options...
Phenomene Posted December 24, 2018 Author Share Posted December 24, 2018 Bonsoir, Merci Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now