X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Limit and Randomize Your Upselling Links (Related Products) (https://forum.x-cart.com/showthread.php?t=17847)

dalmuti 11-09-2005 06:52 AM

Limit and Randomize Your Upselling Links (Related Products)
 
Hello,

This is a simple mod that I hope others might be able to use. I wanted to completely change the product.tpl page and so I've modified it to bring more information higher on the page (above the crease). This mod is specifically about the Upselling Products module.

What I wanted to do:
I have alot of products that have 10-12 upselling links and that would cause my layout to look horrible so I decided to limit the number that would show at any given time to 4. At the same time I didn't want the same 4 to show all the time, I wanted to randomize all 10-12 but only show 4.

View it here: http://www.birdshopper.com/xcart/product.php?productid=45&cat=10&page=1

Change this line in skin1/modules/Upselling_Products/related_products.tpl:
{section name=cat_num loop=$product_links} to look like
{section name=cat_num loop=$product_links max=4}

This is my related_products.tpl:

Code:

{if $product_links ne ""}
{capture name=dialog}
<TABLE width="185" border="0" cellspacing="3">
{section name=cat_num loop=$product_links max=4}<TR>
<TD width="15%" align="center"><a href="product.php?productid={ $product_links[cat_num].productid }">
{include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_x=40 product=$product_links[cat_num].productid}
</a></TD>
<TD width="85%"><A href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} {/if}>
{ $product_links[cat_num].product}
</A>


<FONT class="ProductPrice">Our Price:
{include file="currency.tpl" value=$product_links[cat_num].price}</font>

</TD>
</TR>
<tr>
<td colspan="2"><hr>
</td>
</tr>
{/section}
</TABLE>
{/capture}
{include file="dialog.tpl" title="Customers Also Bought" content=$smarty.capture.dialog extra="width=100%"}
{/if}


In order to randomize all the upselling products, open /modules/Upselling_Products/related_products.php and change the query statement by changing the ORDER BY to ORDER BY RAND()

See my code below:

Code:

if ( !defined('XCART_SESSION_START') ) { header("Location: ../../"); die("Access denied"); }

$product_links = func_query("SELECT DISTINCT $sql_tbl[products].productid, $sql_tbl[products].productcode, MIN($sql_tbl[pricing].price) AS price, IF ($sql_tbl[products_lng].product IS NOT NULL,$sql_tbl[products_lng].product, $sql_tbl[products].product) AS product FROM $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[product_links] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products_lng].productid = $sql_tbl[products].productid AND $sql_tbl[products_lng].code='$store_language' WHERE $sql_tbl[products].productid=$sql_tbl[product_links].productid2 AND $sql_tbl[product_links].productid1='$productid' AND $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0 AND ($sql_tbl[pricing].membership='$membership' OR $sql_tbl[pricing].membership='') AND $sql_tbl[products].forsale='Y' GROUP BY $sql_tbl[products].productid ORDER BY RAND(), product");


$smarty->assign("product_links",$product_links);
?>



Basically 2 lines of code to set max # to show and then to randomize within the product all the upselling links.

Louise

hyratech 12-05-2005 08:48 AM

dalmuti,

Which file and code did u modify to move the related products with PICTRES on the right right? That's exactly what i wanted to do..

I wanted to change the table on product.tp a little bit..
i moved the options and detail above the description..
But i can't get the description to align to the left to start right under the thumbnail picture.
and have the related product showup to the right with it's respective pictures.. that would be PERFECT!
can u help me out?
THanx a mil.

dalmuti 12-05-2005 09:51 AM

The product file to modify is product.tpl. But, I reduced all the code on in the template by creating separate files of each section of the product.tpl and then including them. Makes the code easier to read and follow.

So, I have a productdescription.tpl, a productoption.tpl....etc.

As far as the modification, I use Frontpage....just to get the visual design I want and then copy and paste into X-Cart...making sure not to get a bunch of extra code (as Frontpage is known for).

Here is my product.tpl code:

Code:

{* $Id: product.tpl,v 1.96.2.22 2005/06/03 05:46:02 mclap Exp $ *}
{if $active_modules.Special_Offers}
{include file="modules/Special_Offers/customer/product_offers_short_list.tpl" product=$product}
{/if}
{include file="form_validation_js.tpl"}
{if $product.product_type eq "C" && $active_modules.Product_Configurator}
{include file="modules/Product_Configurator/pconf_customer_product.tpl"}
{else}
{capture name=dialog}
<table border="0" width="760" align="center">
<FORM name="orderform" method="post" action="cart.php?mode=add" onsubmit="javascript: return FormValidation();">
<INPUT type="hidden" name="mode" value="add">
<INPUT type="hidden" name="addproductid" value="{$product.productid}">
<INPUT type="hidden" name="slot" value="{$smarty.get.slot}">
<INPUT type="hidden" name="amount" value="1">
<tr>
<td>
<table border="0" width="100%" id="table1">
<tr>
<td>
<table border="0" width="100%" id="table2">
<tr>
<td width="175" valign="top">{include file="customer/main/product_priceimage.tpl"}</td>
<td width="400" valign="top">{include file="customer/main/product_detailbox.tpl"}</td>
<td width="175" rowspan="2" valign="top">{include file="customer/main/product_boxoptions.tpl"}</td>
</tr>
<tr>
<td colspan="2">{include file="customer/main/product_description.tpl"}</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<INPUT type="hidden" name="productid" value="{$product.productid}">
<INPUT type="hidden" name="cat" value="{$smarty.get.cat|escape:"html"}">
<INPUT type="hidden" name="page" value="{$smarty.get.page|escape:"html"}">
</FORM>
</table>
{/capture}
{include file="dialog.tpl" title=$product.product content=$smarty.capture.dialog extra="width=100%"}
{/if}{if $active_modules.Customer_Reviews ne ""} {include file="modules/Customer_Reviews/vote_reviews.tpl" }
{/if}{include file="product_livehelp.tpl"}
{if $active_modules.Product_Options ne '' && $product_options ne ''}
<SCRIPT type="text/javascript" language="JavaScript 1.2">
check_options();
</SCRIPT>
{/if}


Hope it helps....to understand the concept.

hyratech 12-05-2005 10:25 AM

I kinda get the concept.. but.. there's the deal..

I'm not too good witht he codes..

I got the layout...

working witht he default file.. i did this:

I remove this line:
Code:

{if $product.fulldescr ne ""}{$product.fulldescr}{else}{$product.descr}{/if}

and moved it to a new table right below it .
that table has 2 columns. one for the description. and one saved for the related products..

Her's my question:

what's the include code to get the "upselling" products to show up in that cell? one on top of each other with the pictures?

Thanx alot..

hyratech 12-05-2005 10:28 AM

I hope this helps..
this is my site, please look at it so it'll clear up with what' i'm talking about.

http://<br /> <a href="http://www.atgsm.com/shop/product.php?productid=38&cat=0&page=1" target="_blank">h...ge=1</a><br />

I want to move the "Customer Also Bought" Section to that area with the error codes

dalmuti 12-05-2005 10:33 AM

{ include file = "modules/Upselling_Products/related_products.tpl" }

Did you use the code above. I see a "" at the beginning and end ""?

Louise


All times are GMT -8. The time now is 06:26 AM.

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