Jump to content

séparé En stock hors stock


Recommended Posts

Bonjour à tous,

J'ai trouvé un code qui me permet de séparer les déclinaisons de couleur en stock, hors stock.

 {elseif $group.group_type == 'color'}
        <UL id="group_{$id_attribute_group}">
          {foreach from=$group.attributes key=id_attribute item=group_attribute} 
			 {foreach from=$combinations item=foo}
			 {foreach from=$foo key=key item=floo}
			 {if $key == 'attributes'}
			 {if $floo.0 == $id_attribute}
			 {assign var="verif" value="true"}
			 {else}
			 {assign var="verif" value="false"}
			 {/if}
			 {/if}
			 {if $key == 'quantity' && $verif == 'true'}
			 {if $floo > '0'}  
				<LI class="float-xs-left input-container">
				  <LABEL>
					<INPUT class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
					<SPAN
					  {if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
					  {if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
					><SPAN class="sr-only">{$group_attribute.name}</SPAN></SPAN>
				  </LABEL>
				</LI> 
			 {/if}
			 {/if}
			 {/foreach}
			 {/foreach} 
          {/foreach}
        </UL>	
		
		<DIV class="clearfix"></DIV>
		<SPAN class="control-label">Couleur(s) sur commande</SPAN>
		
		
        <UL id="group_{$id_attribute_group}">
          {foreach from=$group.attributes key=id_attribute item=group_attribute} 
			 {foreach from=$combinations item=foo}
			 {foreach from=$foo key=key item=floo}
			 {if $key == 'attributes'}
			 {if $floo.0 == $id_attribute}
			 {assign var="verif" value="true"}
			 {else}
			 {assign var="verif" value="false"}
			 {/if}
			 {/if}
			 {if $key == 'quantity' && $verif == 'true'}
			 {if $floo == '0'}
				<LI class="float-xs-left input-container">
				  <LABEL>
					<INPUT class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
					<SPAN
					  {if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
					  {if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
					><SPAN class="sr-only">{$group_attribute.name}</SPAN></SPAN>
				  </LABEL>
				</LI> 
			 {/if}
			 {/if}
			 {/foreach}
			 {/foreach} 
          {/foreach}
        </UL>

Le problème étant que lorsque je rajoute des déclinaisons supplémentaires d'un autre type (L,S,M)

Les couleurs se doublent.

Pour l'exemple j'ai ajouté l'option coussin ou non (J'ai ajouté un s entre temps :p)

En stock même couleur deux fois pour oui des coussins, non pas de coussins.

Pareil pour le hors stock.

 

Merci d'avance pour votre aide.

 

probleme.jpg.7595bde10dde3879d11c28a4326aa3d9.jpg

Link to comment
Share on other sites

Voilà comment j'ai fait et ça à l'air de fonctionner.

 

      {elseif $group.group_type == 'color'}
   
		<ul id="group_{$id_attribute_group}" class="" style="border:1px solid #e1e1e1,padding: 10px;">  
			{foreach from=$group.attributes key=id_attribute item=group_attribute}     
				{if ($group.attributes_quantity[{$id_attribute|intval}] != 0)} 
					<li class="float-xs-left input-container">
					  <label>
						<input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
						<span
						  {if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
						  {if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
						><span class="sr-only">{$group_attribute.name}</span></span>
					  </label>
					</li> 	 
				{/if}    
			{/foreach}  
		</ul>
		 
		<div class="clearfix"></div>	
		
		<span class="control-label">{$group.name} sur commande</span>   
		
		<ul id="group_{$id_attribute_group}">  
			{foreach from=$group.attributes key=id_attribute item=group_attribute}     
				{if ($group.attributes_quantity[{$id_attribute|intval}] <= 0)} 
					<li class="float-xs-left input-container"> 
					  <label>
						<input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
						<span
						  {if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
						  {if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
						><span class="sr-only">{$group_attribute.name}</span></span>
					  </label>
					</li> 	 
				{/if}    
			{/foreach} 
		</ul>	

 

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...