X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Variants as table (https://forum.x-cart.com/showthread.php?t=56469)

masada3336 11-08-2010 08:09 PM

Variants as table
 
Hi there all,
I'm trying to get my store working in the 4.4 version (haven't updated my signature - this is still a work in progress). I saw a thread that worked in a previous version to show the variants as a static table above the product details. I'm using the following code and getting basically a blank table - is it a simple syntax issue? This is editing the product_details.tpl and came from this thread: http://forum.x-cart.com/showthread.php?t=14705&highlight=show+all+variants +at+once

Thanks!

Code:

{* Determine if product has variants *}
{if $variants}
       
        <table cellspacing="1" cellpadding="0" border="0" class="chart" width="100%">
       
        {* Build table header *}
        <tr class="chart_head">
          <td>SKU</td>
       
        {* Loop to handle multiple variant names *}
        {foreach from=$product_options item=v}
                {if $v.is_modifier eq ''}<TD>{if $usertype eq "A"}{$v.class}{else}{$v.classtext|default:$v.class}{/if}</TD>{/if}
        {/foreach}
       
          <td>Qty.</td>
          <td>Price</td>
        </tr>
       
        {* Build table rows *}
        {section name=test loop=$variants}
                <tr class="{cycle values="chart_dark,chart_light"}">
                  <td>{$variants[test].productcode}</td>
               
                {* Loop to handle multiple variants *}       
                {foreach name=foo item=item key=key from=$variants[test].options}
                        <td>{$item.option_name}</td>
                {/foreach}
                       
                  <td>{if $JIT eq "yes"}Unlimited{else}{if $variants[test].avail < 1}0{else}{$variants[test].avail}{/if}{/if}</td>
                 
                  <td>${$variants[test].price}</td>
                </tr>
        {/section}
        </table>
       
{/if}


masada3336 12-05-2010 03:46 PM

Re: Variants as table
 
Thought i'd post my solution for 4.4.1:

This is the product variant table as I have it setup thanks to some direction from the board:

Code:

{* Determine if product has variants *}
{if $variants}
    <table class=inlineSpec width="100%">

    {* Build table header *}
    <tr class="specHeader">

    {* Loop to handle multiple variant names *}
    {foreach from=$product_options item=v}
        {if $v.is_modifier eq ''}<TD>{if $usertype eq "A"}{$v.class}{else}{$v.classtext|default:$v.class}{/if}</TD>{/if}
    {/foreach}
      <td >{$lng.lbl_price}</td>
    </tr>

    {* Build table rows *}


    {foreach item=variant from=$variants}
        {assign var=exception value="0"}

        {foreach key=ExceptionKey item=exceptionList from=$product_options_ex}
            {assign var=found value=0}
            {assign var=total value=0}
            {foreach item=classException from=$exceptionList}
                {math assign=total equation="x + 1" x=$total}
                {foreach name=l1 item=variantOpt from=$variant.options}
                    {if $variantOpt.optionid eq $classException.optionid}{math assign=found equation="x + 1" x=$found}{/if}
                {/foreach}
            {/foreach}
            {if $found eq $total}{assign var=exception value="1"}{/if}

        {/foreach}
        {if $exception ne "1"}

            <tr class="specItemHeader{cycle values="1,2"}">
            {* Loop to handle multiple variants *}
            {foreach name=foo item=variantOpt key=key from=$product_options}
                {if $variantOpt.is_modifier eq ''}
                    <TD>
                    {foreach name=bar item=varOpt from=$variant.options}
                        {if $varOpt.classid == $variantOpt.classid}{$varOpt.option_name}{/if}
                    {/foreach}
                    </TD>
                {/if}

            {/foreach}

                <td>{include file="currency.tpl" value=$variant.price}</td>
            </tr>
        {/if}
    {/foreach}
    </table>
{/if}


mizNRG 01-05-2011 05:38 AM

Re: Variants as table
 
I attempted to apply this code and it is causing all of my product descriptions to repeat. Once at the top (above Details and buttons) and once below. This is occuring on all of my products and not just the one with product variants. Any ideas as to why this is happening?


All times are GMT -8. The time now is 05:51 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.