Jump to content

Recommended Posts

I have a products table that has a field called sizing. The sizing field contains an ID from another table called products_sizing. The main reason for the sizing field in the products table is to decipher which products have what kind of sizing method. For instance, some products (shirts) only are available in small and medium not large, but others have the option for all three. In the products table the sizing field shows which sizing method a product will have if any.

 

{foreach from=$SizingMethods key=SizingID item=SizingRow name=SizingMethods}

              {if (what query should go here to only show the sizing methods a certain product has?)}

             

<input name="sizingmethods" type="radio"  id="sizingmethods{$SizingID}" value="{$SizingID}"/>

<label for="sizingmethods{$SizingID}"> {$SizingRow.name} | {if $SizingRow.value ne 0} +{$SizingRow.value} {if $SizingRow.typename eq 'absolute'}{#CURRENCY#}{else}%{/if}{else} {#free#} {/if}</label><br />

                {/if}

{/foreach}

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/203598-if-statement-question/
Share on other sites

Ok here is what I have come up with. The only problem with this code is that if I have more than one product the sizing methods for each product will be the last product to go through the loop. For instance, the first and second product will have the same sizing methods as the third even though the first and second product don't have the same sizing methods. Any ideas on how to fix this? Again this is a Smarty template, and I can use normal coding in the scripts.

 

  {foreach from=$ProdsCarts key=ProductID item=ProductRow name=ProductsLoop}//This goes through how many products there are.

         

          {if $ProductRow.sizing != ''}

         

          <tr class="head">

            <td height="15" colspan="3" style="border:none;"><div align="justify">{#Sizing_Method#} ({$ProductRow.name})</div></td>

          </tr>

  <tr>

        <td colspan="2">

  <div align="left">

 

{foreach from=$ProductSizing key=key item=isOn name=ProductsLoop} // This goes through the sizing methods. Right here I think is the problem. It does not associate with which product the sizing methods go with.

           

<input name="sizingmethods" type="radio"  id="sizingmethods{$SizingID}" value="{$SizingID}"/>

<label for="sizingmethods{$SizingID}"> {$Sizing.$key.name} | {if $Sizing.$key.value ne 0} +{$Sizing.$key.value} {if $Sizing.$key.typename eq 'absolute'}{#CURRENCY#}{else}%{/if}{else} {#free#} {/if}</label><br />

                {/foreach}

          </div></td>

          </tr>

          {else}

          {/if}

          {/foreach}

 

 

Ideas????

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.