View Single Post
  #1  
Old 10-23-2008, 12:40 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Related products: with thb. + N column format + add to cart button.

UPDATE 24-10-2008,
UPDATE 29-10-2008
(sql code)
UPDATE 22-01-2009 (sql code for xcart 4.1.9)

Little mode for Related Product on the detail product page:
a) a "PRODUCT THUMBNAIL PHOTO", will appear in related products
b) they can specify "HOW MANY PRODUCTS, WILL APPEAR" in related products (you can specify this option in the admin area)
c) allow for the "BUY NOW" BUTTON, to appear in related products (you can specify this option in the admin area)

---------------------------------

0. Backup mysql


1. Apply mysql patch:

Code:
insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '', ''); insert into xcart_config VALUES ('related_num_column', 'Display related products list in multiple columns (leave empty to use standard format)', '3', 'Appearance', '5', 'text', '', '', ''); insert into xcart_config VALUES ('related_add_to_cart', 'Enable add to cart button for related products', 'N', 'Appearance', '6', 'checkbox', 'N', '', '');


for version x-cart 4.1.9:

Code:
insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', ''); insert into xcart_config VALUES ('related_num_column', 'Display related products list in multiple columns (leave empty to use standard format)', '3', 'Appearance', '5', 'text', '', ''); insert into xcart_config VALUES ('related_add_to_cart', 'Enable add to cart button for related products', 'N', 'Appearance', '6', 'checkbox', 'N', '');


2. Change file code for "skin1/modules/Upselling_Products/related_products.tpl"

PHP Code:
{* $Idrelated_products.tpl,v 1.15.2.1 2007/05/02 06:05:39 max Exp $ *}

{if 
$product_links ne ""}

{if 
$config.Appearance.related_num_column lte 0}
{
capture name=dialog}
<
table cellspacing="5">
{
section name=cat_num loop=$product_links}
<
tr class="ItemsList">
    <
td width="1%">#{$product_links[cat_num].productid}</td>
    
<td width="99%"><a href="product.php?productid={$product_links[cat_num].productid}"{if $config.Upselling_Products.upselling_new_window eq 'Y'target="_blank"{/if} class="ItemsList">{$product_links[cat_num].product|amp}</a></td>
</
tr>
{/
section}
</
table>
{/
capture}
{include 
file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra='width="100%"'}

{else}

{
capture name=dialog}

{
assign var="count_per_row" value=`$config.Appearance.related_num_column`}

{
math equation="floor(100/x)" x=$count_per_row assign="width"}
{
assign var="count" value=0}

<
table width="100%">
{
section loop=$product_links name=proid}
        {if 
$count is div by $count_per_row}
            <
tr>
            {
assign var="count" value=0}
        {/if}

        <
td width="{$width}%" height="100%" align="center" valign="top" >

            <
a href="product.php?productid={$product_links[proid].productid}class="ItemsList">{$product_links[proid].product}</a><br />
            <
a href="product.php?productid={$product_links[proid].productid}"{if $config.Modules.upselling_new_window eq 'Y'target="_blank"{/if}>
                {include 
file="product_thumbnail.tpl" productid=$product_links[proid].productid image_x=$config.Appearance.thumbnail_width tmbn_url=$product_links[proid].tmbn_url}
            </
a>
            <
br />
            <
font class="ProductPrice">{$lng.lbl_our_price}: {include file="currency.tpl" value=$product_links[proid].taxed_price}</font>
            <
br /><br />
            {if 
$config.Appearance.related_add_to_cart eq "Y"}
                {if 
$config.General.unlimited_products eq "Y" || $product_links[proid].avail gt 0}
                    {include 
file="buttons/button.tpl" style="button" button_title=$lng.lbl_add_to_cart href="javascript: self.location='cart.php?mode=add&productid=`$product_links[proid].productid`&amount=1'"}
                {else}
                    <
b>{$lng.txt_out_of_stock}</b>
                {/if}
            {/if}
        </
td>

        {
capture name=prod_index}
            {
math equation="index+x+1" index=$count x=$count_per_row}
        {/
capture}
        
        {if 
$smarty.capture.prod_index is div by $count_per_row}
            </
tr>
            <
tr>
                <
td colspan="{$count_per_row}"><hr></td>
            </
tr>
        {/if}
        {
math equation="x+1" x=$count assign="count" }

{/
section}
{if 
$count lt $count_per_row}
{
section name=rest_cells loop=$count_per_row start=$count}
    <
td class="SectionBox">&nbsp;</td>
{/
section}
{/if}
</
tr>
</
table>

{/
capture}
{include 
file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra='width="100%"'}

{/if}
{/if} 


PS. Tested for xcart 4.1.9 - 4.1.11.
PS2. I would be grateful for any comments on that decision.

Product details page:
Click image for larger version

Name:	first.JPG
Views:	375
Size:	18.1 KB
ID:	1190

Admin area:
Click image for larger version

Name:	seond.JPG
Views:	300
Size:	16.5 KB
ID:	1191
Reply With Quote