Jump to content

[RESOLU] Select Attribut, jquery et product.tpl


Recommended Posts

Salut à tous,

 

Sur ma page product.tpl, je souhaite 'personnaliser' le select d'un attribut/group_attribut (un seul) via un plugin jquery (http://designwithpc....ns/ddSlick#demo)

 

Mon but final (encore très loin) étant d'arriver à un résultat similaire à celui-ci:

post-336460-0-31132100-1350638556_thumb.jpg

J'élude (pour le moment) le fait de récupérer les attributs dans toutes les langues.

 

J'ai réussi à 'isoler' mon groupe d'attribut dans product.tpl, afin qu'il n'est pas le même comportement que les autres (on dira que je bosse sur le group1):


							{foreach from=$groups key=id_attribute_group item=group}
									{if $group.attributes|@count}
										{if $id_attribute_group<>1}

											<p>
												<label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :  </label>
												{assign var="groupName" value="group_$id_attribute_group"}
												<select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};">
													{foreach from=$group.attributes key=id_attribute item=group_attribute}
														<option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>
													{/foreach}
												</select>
											</p> {else}

											<!-- Ca se passe ici pour mon Attribut 'Spécial' -->
											<p>
												<label for="group_1">{$group.name|escape:'htmlall':'UTF-8'} :  ddd</label>
												{assign var="groupName" value="group_1"}
												<select name="{$groupName}" id="group_1">
													{foreach from=$group.attributes key=id_attribute item=group_attribute}
														<option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>
													{/foreach}
												</select>
											</p>
											<script type="text/javascript">
												// <![CDATA[

												$('#group_1').ddslick({

												selectText: "Select ta capa",

												onSelected: function(data){
													  console.log(data.selectedData.value);
												}
											});


											// ]]>
											</script>
										{/if} <!-- FIN mon Attribut 'Spécial' -->
									{/if}  
								{/foreach}

 

 

Jusque là tout va bien...et le 1er couak...comment passer la valeur de mon select?

 

J'avoue que n’étant pas une bête en jquery (et j'ai prestashop dans les mains depuis peu de temps), je suis un peu perdue dans le système de 'combinations' du product.js

Si j'ai bien compris (pas sûre sur ce coup), j'ai un tableau de 'combinations' généré au chargement de la page (function addCombination) et chaque fois que je change mon select celui-ci va vérifier si la combinaison existe (function findCombination) et met à jour (function updateDisplay) quantité, prix....

 

Dans mon $('#group_1').ddslick, j'ai tenté d'appeler findCombination...sans résultat. (en fait je ne sais quoi lui envoyer) (juste la value...ne lui convient pas apparemment)

 

Quelqu'un aurait une piste? Un tuto ? Une idée? A déja tenté ce cas de figure?

 

Voilà 2 screens sans mon dropdown et avec

post-336460-0-77140800-1350641596_thumb.jpg post-336460-0-43965300-1350641627_thumb.jpg

 

Merci par avance

 

EDIT RESOLU :

Pour ceux que ca interesse dans le product.js

 

trouver

//create a temporary 'choice' array containing the choices of the customer
var choice = new Array();
$('div#attributes select').each(function(){
 choice.push($(this).val());
});

rajouter en dessous

   $('div#attributes .dd-selected-value').each(function(){
 choice.push($(this).val());
});

 

Dans product.tpl suffit de mettre ça

	 <script type="text/javascript">
								    // <![CDATA[

								    $('#group_1').ddslick({

								    selectText: "Select ta capa",
								    onSelected: function(data){
								    //console.log(data.selectedData.value);
								   // updateTamere();
								   findCombination();
							    }
						    });


						    // ]]>
							    </script>

Edited by ginfizzz (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...