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)
-   -   Extra Fields 4.2.x on Products_list.tpl (https://forum.x-cart.com/showthread.php?t=49503)

Ordorica 09-02-2009 06:53 PM

Extra Fields 4.2.x on Products_list.tpl
 
Hi Guys,

I have searched the forum and looked at http://forum.x-cart.com/showthread.php?t=25143&highlight=extra+field in detail but I still can't get my extra fields to show in products_list.tpl

I have made the following change to products.php:

Code:

    include $xcart_dir."/modules/Subscriptions/subscription.php";
}

if (!empty($active_modules["Extra_Fields"]) && !empty($products)) {
foreach($products as $k => $v) {
$products[$k]["extra_fields"] = func_query("SELECT $sql_tbl[extra_fields].field as field, $sql_tbl[extra_field_values].value as value, $sql_tbl[extra_fields].service_name as service_name FROM $sql_tbl[extra_fields], $sql_tbl[extra_field_values] WHERE $sql_tbl[extra_field_values].fieldid = $sql_tbl[extra_fields].fieldid AND $sql_tbl[extra_field_values].productid = '$v[productid]'");
}
}

$smarty->assign("cat_products", $products);

$smarty->assign("navigation_script", "home.php?cat=$cat&sort=$sort&sort_direction=$sort_direction");


...and I have added the following code to products_list.tpl:

Code:

              {if $active_modules.Special_Offers ne "" && $product.use_special_price ne ""}
                {include file="modules/Special_Offers/customer/product_special_price.tpl"}
              {/if}
            {else}
              <span class="price">{$lng.lbl_enter_your_price}</span><br />
              {$lng.lbl_enter_your_price_note}
            {/if}
          {/if}
         
{if $extra_fields[field].field eq "Stock Availability (Approx.)" && $extra_fields[field].field_value ne ""}
        {if $extra_fields[field].field_value eq ">5"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td><img src="/skin1/images/quantity/qty_gt5.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
        </tr>
        {/if}
       
        {if $extra_fields[field].field_value eq "5"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td><img src="/skin1/images/quantity/qty_5.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
        </tr>
        {/if}
        {if $extra_fields[field].field_value eq "4"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td><img src="/skin1/images/quantity/qty_4.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
        </tr>
        {/if}
        {if $extra_fields[field].field_value eq "3"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td><img src="/skin1/images/quantity/qty_3.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
        </tr>
        {/if}
        {if $extra_fields[field].field_value eq "2"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td><img src="/skin1/images/quantity/qty_2.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
        </tr>
        {/if}
        {if $extra_fields[field].field_value eq "1"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td><img src="/skin1/images/quantity/qty_1.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
        </tr>
        {/if}
        {if $extra_fields[field].field_value eq "0"}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td>BY ORDER</a></td>
        </tr>
        {/if}
        {if $extra_fields[field].field_value eq ""}
        <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        <td>BY ORDER</a></td>
        </tr>
        {/if}
{/if}

          {if $product.appearance.buy_now_enabled}
            {include file="customer/main/buy_now.tpl"}
          {/if}
        {/if}
        </div>


The extra fields works fine on my product details page so I have used the same code in the products_list.tpl but I can't get the extra fields to appear.

I would really appreciate some help on this.

lkrivoshiev 09-06-2009 11:28 PM

Re: Extra Fields 4.2.x on Products_list.tpl
 
2 Attachment(s)
Hi Ordorica, I had the same problem and QT helped me. Now it works. Anton Sologubov developed this mod. Here is the message:
================================================== ======
I've modified the following files to implement the modification you meant: * home.php * skin2/customer/main/products_list.tpl and looks that it works properly.
================================================== ======
Here I apply my modified files: Attachment 1657 Attachment 1658

I think is better to extract the needed code. I hope this will help you.



Lyubomir Krivoshiev
www.computer-expert.bg

Ordorica 09-07-2009 02:48 AM

Re: Extra Fields 4.2.x on Products_list.tpl
 
Hi lkrivoshiev,

Thank you so much for your reply. With your help I have managed to achieve what I was attempting. My results are posted here for the benefit of others.

In home.php I made the following changes.

Added:

Code:

if((isset($products)) && (is_array($products))){
    foreach ($products as $product){
        $custom_extra_fields[$product['productid']] = func_query("SELECT exvalues.* , exfields.field FROM $sql_tbl[extra_field_values] as exvalues, $sql_tbl[extra_fields] as exfields WHERE exvalues.productid='".intval($product['productid'])."' AND exvalues.fieldid=exfields.fieldid");
    }
}

if (isset($custom_extra_fields))
$smarty->assign('custom_extra_fields',$custom_extra_fields);


before the line:
if ($active_modules["Bestsellers"])

In products_list.tpl I added the following code to display the desired extra field data:

Code:

        {foreach from=$custom_extra_fields item="exfields"}
          {foreach from=$exfields item="cur_exfiled"}
                    {if $product.productid eq $cur_exfiled.productid && $cur_exfiled.fieldid eq '11'}
                {if $cur_exfiled.value eq ">5"}
                <tr>
                <td>Stock: </td>
                <td><img src="/skin1/images/quantity/qty_gt5.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
                </tr>
                    {/if}
                {if $cur_exfiled.value eq "5"}
                <tr>
                <td>Stock: </td>
                <td><img src="/skin1/images/quantity/qty_5.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
                </tr>
                    {/if}
                {if $cur_exfiled.value eq "4"}
                <tr>
                <td>Stock: </td>
                <td><img src="/skin1/images/quantity/qty_4.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
                </tr>
                    {/if}
                {if $cur_exfiled.value eq "3"}
                <tr>
                <td>Stock: </td>
                <td><img src="/skin1/images/quantity/qty_3.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
                </tr>
                    {/if}
                {if $cur_exfiled.value eq "2"}
                <tr>
                <td>Stock: </td>
                <td><img src="/skin1/images/quantity/qty_2.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
                </tr>
                    {/if}
                {if $cur_exfiled.value eq "1"}
                <tr>
                <td>Stock: </td>
                <td><img src="/skin1/images/quantity/qty_1.gif" alt=" " title=" " border="0" height="11" width="40"></a></td>
                </tr>
                    {/if}
                {if $cur_exfiled.value eq "0"}
                <tr>
                <td>Stock: </td>
                <td>BY ORDER</td>
                </tr>
                    {/if}
                    {/if}
          {/foreach} 
        {/foreach}


the above code was added before the line:
{if $product.appearance.buy_now_enabled}

Thanks again, much appreciated.

TheWrongGrape 05-12-2010 05:37 PM

Re: Extra Fields 4.2.x on Products_list.tpl
 
Just wanted to add that I tried this and it's not working in 4.3.1. :-(

Edit: Got it working now: http://forum.x-cart.com/showpost.php?p=287479&postcount=10


All times are GMT -8. The time now is 06:14 PM.

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