Jump to content

Color declination


Recommended Posts

Hello,

I have recovered a code which allows to separate the declensions of colors in two:
In stock
Not in stock

This code works perfectly except when I add a second size variation for example,

In this case he doubles my colors

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

Thank you in advance for your help

probleme.jpg

Link to comment
Share on other sites

Voilà

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

 

Edited by Nocebo (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...