So I figured out a way to get accessories to list under certain products.
It's crude but it works. But I get the feeling that the method im using is not exactly the most optimal way.
Here is a working example that I have done:
http://headsetinnovations.com/cart/product.php?productid=16266&cat=250&page=1
How I did it:
-I created a folder in skin1 called 'subaccess' .
-Then you want to have all your accessories in a category.
Then what I did was edit customer/main/product.tpl
and at the bottom added
Code:
{include file="subaccess/subaccessif.tpl"}
Create subaccess.php in /cart folder with code:
Code:
<?php
#
# $Id: home.php,v 1.1.2.7 2005/01/12 07:41:42 svowl Exp $
#
define('OFFERS_DONT_SHOW_NEW',1);
require "./auth.php";
require $xcart_dir."/include/categories.php";
if ($active_modules["Manufacturers"])
include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";
if (empty($products))
include "./featured_products.php";
if (!empty($cat))
include "./products.php";
if($active_modules["Bestsellers"])
include $xcart_dir."/modules/Bestsellers/bestsellers.php";
if (!empty($current_category) and is_array($current_category["category_location"])) {
foreach ($current_category["category_location"] as $k=>$v)
$location[] = $v;
}
if (!empty($active_modules["Special_Offers"])) {
include $xcart_dir."/modules/Special_Offers/category_offers.php";
}
#
# Assign Smarty variables and show template
#
$smarty->assign("main","catalog");
# Assign the current location line
$smarty->assign("location", $location);
# Transfer mode http or https
$smarty->assign("tmode", $tmode);
func_display("subaccess/subaccessdiag.tpl",$smarty);
?>
Modify subaccessdiag.tpl to the way you want it setup.
(this is how your accessories will list)
My subaccessdiag.tpl:
Code:
{capture name=dialogacc}{section name=product loop=$products}{assign var="discount" value=0}
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><A href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}" class="ProductTitle">
{$products[product].product}<span style="text-decoration: none"></span></font></A></td>
<td nowrap valign="top">
<p align="right"><font color="#333333">{$products[product].productcode}</font></td>
</tr>
<tr>
<td width="100%" colspan="2">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="2" valign="top">
<p align="left"><A href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}">{if $tmode eq "HTTPS"}{include file="product_thumbnail_secure.tpl" productid=$products[product].productid product=$products[product].product tmbn_url=$products[product].tmbn_url}{else}{include file="product_thumbnail.tpl" productid=$products[product].productid product=$products[product].product tmbn_url=$products[product].tmbn_url}{/if}
[img]{$ImagesDir}/viewdetails.gif[/img]</A><td valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" valign="top">
<p style="margin-left: 2px"><font size="2">{$products[product].descr}</font></td>
<td valign="top">
<p style="margin-left: 2px">{if $products[product].taxed_price ne 0}
{if $products[product].list_price gt 0 and $products[product].taxed_price lt $products[product].list_price}
{math equation="100-(price/lprice)*100" price=$products[product].taxed_price lprice=$products[product].list_price format="%d" assign=discount}
{math equation="lprice-price" price=$products[product].taxed_price lprice=$products[product].list_price assign=discountsum}
{if $discount gt 0}
{$lng.lbl_market_price}: <font color="#333333">{include file="currency.tpl" value=$products[product].list_price}</font></FONT>
{/if}
{/if}
<FONT class="ProductPrice">{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].taxed_price}</FONT>
<FONT class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</FONT>{if $discount gt 0}You Save:
{include file="currency.tpl" value=$discountsum}{/if}
{if $products[product].taxes}
{include file="customer/main/taxed_price.tpl" taxes=$products[product].taxes}{/if}
{else}
<FONT class="ProductPrice">{$lng.lbl_enter_your_price}</FONT>
{/if}
{if $active_modules.Feature_Comparison ne '' && $products[product].fclassid > 0}
{include file="modules/Feature_Comparison/compare_checkbox.tpl" id=$products[product].productid}
{/if}
{include file="customer/main/buy_now.tpl" product=$products[product]}
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
[img]{$ImagesDir}/productshr.gif[/img]
</p>{/section}
{/capture}
{include file="dialog.tpl" title="Accessories for this product" content=$smarty.capture.dialogacc extra="width=100%"}
Then for subaccess/subaccessif.tpl I had this:
(This is what determines what products have what accessories.)
Code:
{* determine if user is in HTTP or HTTPS *}
{php}
if ($HTTP_SERVER_VARS[SERVER_PORT] == 80)
{
$protocol = "http";
}
elseif ($HTTP_SERVER_VARS[SERVER_PORT] == 443)
{
$protocol = "https";
}
global $protocol;
{/php}
{* Association with Products & Accessories *}
{if $product.productid eq "16133"}
{php} include 'http://headsetinnovations.com/cart/subaccess.php?cat=321&tmode='.$protocol; {/php}
{elseif $product.productid eq "16134"}
{php} include 'http://headsetinnovations.com/cart/subaccess.php?cat=372&tmode='.$protocol; {/php}
{/if}
How the above code works:
If you want to have an accessories listing for product id 16124 then you would add an extra line of this: {elseif $product.productid eq "16134"}
then you would want specify what category id with the accessories to list for that product. {php} include 'http://headsetinnovations.com/cart/subaccess.php?cat=345&tmode='.$protocol; {/php} cat=345 would be the category id you want to list. Also &tmode= is important because if a customer goes to your site in secure mode (https) you will get a "Insecure Items" warning in IE. Because your are including a webpage php doesn't know the difference between secure and non secure. So the images are included the way they are called up. Hopefully that made sense to anyone.
add product_thumbnail_secure.tpl in your /skin1 folder with following code:
Code:
{* $Id: product_thumbnail.tpl,v 1.14 2004/06/24 09:53:29 max Exp $ *}
{if $config.Appearance.show_thumbnails eq "Y"}[img]{if $tmbn_url}{$tmbn_url|replace:[/img]{/if}
What I was wondering is if anyone has already done something like this or has a better idea on doing the subaccessif.tpl template. so its not full with smarty {elseif} tags...