jherbaux Posted December 24, 2009 Share Posted December 24, 2009 Bonjour,quand l'on fait une commande (partie client bien sur).Comment notre ami prestashop mémorise t-il les attribut d'une commande?par exemple, je choisis une couleur, comment prestashop fait-il pour la mettre dans le panier? Il passe par un fichier JS mais comment?c'est donc cette ligne dans product.tpl quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p> donc je suis perdu..merci de votre aide Link to comment Share on other sites More sharing options...
Yoya Posted December 24, 2009 Share Posted December 24, 2009 Tu parles du bouton ajouter au panier dans la page produit.tpl et de l'envoie en asynchrone par ajax ? Link to comment Share on other sites More sharing options...
jherbaux Posted December 24, 2009 Author Share Posted December 24, 2009 c'est le bon bouton ui, je veux savoir comment il envoie l'information couleur entre le moment ou l'on clique et le moment ou il s'affiche sur la droite(dans le panier). Link to comment Share on other sites More sharing options...
Yoya Posted December 24, 2009 Share Posted December 24, 2009 il faut aller voir dans ajax-cart.js Link to comment Share on other sites More sharing options...
jherbaux Posted December 24, 2009 Author Share Posted December 24, 2009 merci de ton aideBon j'ai regardé ce fichiersi j'ai bien compris c'est ce bout de code qui fait que la couleur est enregistré. //for product page 'add' button... $('body#product p#add_to_cart input').unbind('click').click(function(){ ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null); return false; }); et donc il prend la couleur grâce a $('#idCombination').val() ????et donc il faudrait filler ce paramètre dans la page catégory pour pouvoir sélectionner les couleurs?Je sais pas si je suis très clair ... :s Link to comment Share on other sites More sharing options...
Yoya Posted December 24, 2009 Share Posted December 24, 2009 Oui c'est tout à fait çà Link to comment Share on other sites More sharing options...
jherbaux Posted December 24, 2009 Author Share Posted December 24, 2009 Ce que je ne comprend pas c'est comment il prend cette valeur car dans la ligne quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p> il n'y a aucun info dessus... Il y a bien ce JS la {if isset($groups)} // Combinations {foreach from=$combinations key=idCombination item=combination} addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}'); {/foreach} // Colors {if $colors|@count > 0} {if $product->id_color_default}var id_color_default = {$product->id_color_default|intval};{/if} {/if} {/if} c'est a lui qui faut filler les infos?Ah et.. Joyeux noël ^^ Link to comment Share on other sites More sharing options...
Yoya Posted December 24, 2009 Share Posted December 24, 2009 Dans ajax-cart.js, les actions des boutons click sont modifié par JQuery (bind). Link to comment Share on other sites More sharing options...
jherbaux Posted December 28, 2009 Author Share Posted December 28, 2009 je séche, put-on m'éclairer a propose de bond? je comprend pas trop svp Link to comment Share on other sites More sharing options...
Yoya Posted December 28, 2009 Share Posted December 28, 2009 Salut jherbaux,Le fichier ajax-cart.js réécrit les actions click de ton bouton add ici : //for product page 'add' button... $('body#product p#add_to_cart input').unbind('click').click(function() { ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null); return false; }); Donc quand tu clique sur "ajouter" c'est la fonction ajaxCart.add qui est appelée avec entr autre comme paramètre le contenur du div invisible "idCombination"Quand tu sélectionnes une déclinaison, la fonction findCombination() de product.js est appelé et renseigne le div invisible "idCombination".Voilou.Pierre. Link to comment Share on other sites More sharing options...
jherbaux Posted December 28, 2009 Author Share Posted December 28, 2009 Et oui je nage toujours...Donc j'arrive a avoir ls couleurs sur ma page j'ai fait un copier/coller du javascript de la page product.tpl [removed] // <![CDATA[ // PrestaShop internal settings var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}'; var currencyRate = '{$currencyRate|floatval}'; var currencyFormat = '{$currencyFormat|intval}'; var currencyBlank = '{$currencyBlank|intval}'; var taxRate = {$product->tax_rate|floatval}; var jqZoomEnabled = {if $jqZoomEnabled}true{else}false{/if}; //JS Hook var oosHookJsCodeFunctions = new Array(); // Parameters var id_product = '{$product->id|intval}'; var productHasAttributes = {if isset($groups)}true{else}false{/if}; var quantitiesDisplayAllowed = {if $display_qties == 1}true{else}false{/if}; var quantityAvailable = {if $display_qties == 1 && $product->quantity}{$product->quantity}{else}0{/if}; var allowBuyWhenOutOfStock = {if $allow_oosp == 1}true{else}false{/if}; var availableNowValue = '{$product->available_now|escape:'quotes':'UTF-8'}'; var availableLaterValue = '{$product->available_later|escape:'quotes':'UTF-8'}'; var productPriceWithoutReduction = {$product->getPriceWithoutReduct()|default:'null'}; var reduction_percent = {if $product->reduction_percent}{$product->reduction_percent}{else}0{/if}; var reduction_price = {if $product->reduction_percent}0{else}{$product->getPrice(true, $smarty.const.NULL, 2, $smarty.const.NULL, true)}{/if}; var reduction_from = '{$product->reduction_from}'; var reduction_to = '{$product->reduction_to}'; var group_reduction = '{$group_reduction}'; var default_eco_tax = {$product->ecotax}; var currentDate = '{$smarty.now|date_format:'%Y-%m-%d'}'; var maxQuantityToAllowDisplayOfLastQuantityMessage = {$last_qties}; var noTaxForThisProduct = {if $no_tax == 1}true{else}false{/if}; var displayPrice = {$priceDisplay}; // Customizable field var img_ps_dir = '{$img_ps_dir}'; var customizationFields = new Array(); {assign var='imgIndex' value=0} {assign var='textFieldIndex' value=0} {foreach from=$customizationFields item='field' name='customizationFields'} {assign var='key' value='pictures_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field} customizationFields[{$smarty.foreach.customizationFields.index|intval}] = new Array(); customizationFields[{$smarty.foreach.customizationFields.index|intval}][0] = '{if $field.type|intval == 0}img{$imgIndex++}{else}textField{$textFieldIndex++}{/if}'; customizationFields[{$smarty.foreach.customizationFields.index|intval}][1] = {if $field.type|intval == 0 AND $pictures.$key}2{else}{$field.required|intval}{/if}; {/foreach} // Images var img_prod_dir = '{$img_prod_dir}'; var combinationImages = new Array(); {foreach from=$combinationImages item='combination' key='combinationId' name='f_combinationImages'} combinationImages[{$combinationId}] = new Array(); {foreach from=$combination item='image' name='f_combinationImage'} combinationImages[{$combinationId}][{$smarty.foreach.f_combinationImage.index}] = {$image.id_image|intval}; {/foreach} {/foreach} combinationImages[0] = new Array(); {foreach from=$images item='image' name='f_defaultImages'} combinationImages[0][{$smarty.foreach.f_defaultImages.index}] = {$image.id_image}; {/foreach} // Translations var doesntExist = '{l s='The product does not exist in this model. Please choose another.' js=1}'; var doesntExistNoMore = '{l s='This product is no longer in stock' js=1}'; var doesntExistNoMoreBut = '{l s='with those attributes but is available with others' js=1}'; var uploading_in_progress = '{l s='Uploading in progress, please wait...' js=1}'; var fieldRequired = '{l s='Please fill all required fields' js=1}'; {if isset($groups)} // Combinations {foreach from=$combinations key=idCombination item=combination} addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}'); {/foreach} // Colors {if $colors|@count > 0} {if $product->id_color_default}var id_color_default = {$product->id_color_default|intval};{/if} {/if} {/if} //]]> [removed] que j'ai copier dans product-list.tpl.Mais ce JS n'est jamais appelé...Et comme dedans il y a ces lignes {if isset($groups)} // Combinations {foreach from=$combinations key=idCombination item=combination} addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}'); {/foreach} // Colors {if $colors|@count > 0} {if $product->id_color_default}var id_color_default = {$product->id_color_default|intval};{/if} {/if} {/if} //]]> [removed] Je pense que c'est pour sa que mes couleurs ne marchent pas...Y a t il un moyen de vérifier? Enfin je sais pas si vous avez des idées je suis preneur... Link to comment Share on other sites More sharing options...
jherbaux Posted December 28, 2009 Author Share Posted December 28, 2009 désoler pour le double post mais pas asser de place ^^page product-list.tpl (le JS est deja copier je le remet pas) >{if isset($products)} <!--Le code JS --> </pre> <ul> {foreach from=$products item=product key=test name=products} {if ($product.allow_oosp OR $product.quantity > 0)}{l s='Available'}{else}{l s='Out of stock'}{/if} <!--image produit getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />--> {if $product.new == 1}{l s='new'}{/if}{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'} {$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'} <!-- add to cart form--> <!-- add to cart form--> <form id="buy_block" action="{$base_dir}cart.php" method="post"> <!-- hidden datas --> <input type="hidden" name="token" value="{$static_token}" /> <input type="hidden" name="id_product" value="{$product.id_product|intval}" id="product_page_product_id" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="id_product_attribute" id="idCombination" value="" /> <!-- prices --> {if isset($groups)} <!--{$groups|print_r}--> <!-- attributes --> {foreach from=$groups key=id_attribute_group item=group} {$group.name|escape:'htmlall':'UTF-8'} : {assign var='groupName' value='group_'|cat:$id_attribute_group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {$group_attribute|escape:'htmlall':'UTF-8'} {/foreach} {/foreach} {/if} {if $product->reference} {l s='Reference :'} {$product->reference|escape}{/if} <!-- quantity wanted --> quantity == 0) || $virtual} style="display:none;"{/if}> {l s='Quantity :'} <input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}1{/if}" size="2" maxlength="3" /> <!-- availability --> quantity == 0 && !$product->available_later) || (!$product->available_now && $display_qties != 1) } style="display:none;"{/if}> {l s='Availability:'} quantity == 0} class="warning-inline"{/if}> {if $product->quantity == 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if} <!-- 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 < 2} style="display:none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'} <!-- Out of stock hook --> quantity > 0} style="display:none;"{/if}> {$HOOK_PRODUCT_OOS} quantity > $last_qties || $product->quantity == 0) || $allow_oosp} style="display:none;"{/if} >{l s='Warning: Last items in stock!'} <input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p> {if $HOOK_PRODUCT_ACTIONS} {$HOOK_PRODUCT_ACTIONS} {/if} </form> {/foreach} </ul> <br> <!-- /Products list --><br>{/if Link to comment Share on other sites More sharing options...
jherbaux Posted December 28, 2009 Author Share Posted December 28, 2009 Il semblerai que "tous" soit fonctionnnelle sauf l'appel à la fonction onchange="[removed]findCombination(); Pourtant il me semble que je ne me trompe pas pour l'appel de la fonction ? {if isset($groups)} <!-- attributes --> {foreach from=$groups key=id_attribute_group item=group} {$group.name|escape:'htmlall':'UTF-8'} : {assign var='groupName' value='group_'|cat:$id_attribute_group} {foreach from=$group.attributes key=id_attribute item=group_attribute} {$group_attribute|escape:'htmlall':'UTF-8'} {/foreach} {/foreach} {/if} Sachant que je suis toujours dans le fichier product-list.tpl Merci de vos réponses Link to comment Share on other sites More sharing options...
jherbaux Posted December 28, 2009 Author Share Posted December 28, 2009 je me rend compte que le fichier contenant la fonction products.js contenant la fonction findCombination() n'est pas appellé dans la page category.php alors j'ai fais un $js_files = array( __PS_BASE_URI__.'js/jquery/thickbox-modified.js', __PS_BASE_URI__.'js/jquery/jquery.idTabs.modified.js', __PS_BASE_URI__.'js/jquery/jquery.scrollto.js', __PS_BASE_URI__.'js/jquery/jquery.serialScroll.js', _THEME_JS_DIR_.'tools.js', _THEME_JS_DIR_.'product.js' ); mais sa n'a pas marché... un peu d'aide svp...trouvé je l'est appeller en jsmais je n'est toujours pas mes couleurs :sJe suis bloqué a cette ligne la dans la fonction findCombination() for (combination in combinations) Si quelqu'un a une idée pour me débugger ou me proposer des choses, il est le bien venu Link to comment Share on other sites More sharing options...
Yoya Posted December 29, 2009 Share Posted December 29, 2009 Yo jherbaux !T'es en train de me dire que tu souhaites récupérer tes couleurs dans category.tpl, là où tous les produits sont affichés en ligne ? Link to comment Share on other sites More sharing options...
jherbaux Posted December 29, 2009 Author Share Posted December 29, 2009 oui c'est cela, dit moi qui a un menu tous fait lolJ'ai réussis a récupérer mes couleurs mais je n'arrive pas a les selectionner dans ma commande, il garde la couleur mise en defaut Link to comment Share on other sites More sharing options...
Yoya Posted December 29, 2009 Share Posted December 29, 2009 Mouai ...Tous çà pour dire que efectivement mes explications ne collent pas car tu m'avais dis qu'il sagissait de product.tpl, ce qui n'est pas le cas.Y'a plusieurs discutions d'ouvertent sur le sujet qui t'interessent sinon. Link to comment Share on other sites More sharing options...
jherbaux Posted December 29, 2009 Author Share Posted December 29, 2009 en fait c'est dans le product-list.tpl, qui se trouve effectivement dans le category.tplJe vais chercher les sujets auxquelles tu parles Link to comment Share on other sites More sharing options...
jherbaux Posted December 29, 2009 Author Share Posted December 29, 2009 En effet beaucoup de sujet en parle, mais la plus part n'y arrive pas ou veulent juste les afficher, moi je veux pouvoir les sélectionner de là.Je pense avoir bien avancé mais je n'y arrive toujours pas.je ne passe pas l'étape for (combination in combinations) dans la fonction : function findCombination(firstTime)Sauf quand je retire la ligne var maxQuantityToAllowDisplayOfLastQuantityMessage = {$last_qties}; de mon fichier product-list.tpl.Le problème vien donc surement de la variable $last_qties.Si quelqu'un a des idées.... Merci Link to comment Share on other sites More sharing options...
davidan Posted November 1, 2010 Share Posted November 1, 2010 Bonjour,Avez-vous réussi à faire apparaitre les déclinaisons dans le product-list ?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