Below is an update to my modified customer/products.php page for displaying options on the products.tpl page.
Code:
<?
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2002 Ruslan R. Fazliev. All rights reserved. |
+-----------------------------------------------------------------------------+
| The Ruslan R. Fazliev forbids, under any circumstances, the unauthorized |
| reproduction of software or use of illegally obtained software. Making |
| illegal copies of software is prohibited. Individuals who violate copyright |
| law and software licensing agreements may be subject to criminal or civil |
| action by the owner of the copyright. |
| |
| 1. It is illegal to copy a software, and install that single program for |
| simultaneous use on multiple machines. |
| |
| 2. Unauthorized copies of software may not be used in any way. This applies |
| even though you yourself may not have made the illegal copy. |
| |
| 3. Purchase of the appropriate number of copies of a software is necessary |
| for maintaining legal status. |
| |
| DISCLAIMER |
| |
| THIS SOFTWARE IS PROVIDED BY Ruslan R. Fazliev ``AS IS'' AND ANY |
| EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| DISCLAIMED. IN NO EVENT SHALL Ruslan R. Fazliev OR ITS |
| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev. |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2002 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\*****************************************************************************/
#
# $Id: products.php,v 1.30 2002/11/19 12:06:10 alfiya Exp $
#
# Navigation code
#
$objects_per_page = $config["General"]["products_per_page"];
$total_nav_pages = ceil($current_category["product_count"]/$config["General"]["products_per_page"])+1;
require "../include/navigation.php";
if($active_modules["Advanced_Statistics"])
include "../modules/Advanced_Statistics/cat_viewed.php";
#
# Get products data for current category and store it into $products array
#
$search_query = "($sql_tbl[products].categoryid='$cat' or $sql_tbl[products].categoryid1='$cat' or $sql_tbl[products].categoryid2='$cat' or $sql_tbl[products].categoryid3='$cat') and $sql_tbl[products].forsale='Y'";
$products = func_search_products($search_query, $user_account['membership'], $first_page,$current_category["product_count"]);
if (count($products) ==0) $products="";
if($active_modules["Subscriptions"]) {
include "../modules/Subscriptions/subscription.php";
}
// Begin Product Options Mod by Brett Brewer
if(is_array($products))
foreach($products as $key=>$value){
// first we loop through the products and get their options if they have any
$query="SELECT * from $sql_tbl[product_options],$sql_tbl[product_options_js] WHERE $sql_tbl[product_options].productid='$value[productid]' AND $sql_tbl[product_options_js].productid='$value[productid]'";
$products[$key]['product_options']=func_query($query);
}
// now we loop through the products again and parse the options
if(is_array($products))
foreach($products as $key=>$value){
if(is_array($value['product_options']))
foreach($value['product_options'] as $k=>$v){
//we need to parse the options so that the template can understand them...
// this is brute force value grabbing...the index 4 should be changed to a reference to an associative array index,
// but I didn't see it when viewing the variables in the modified x-cart debugger window.
$products[$key]['product_options'][$k]['options']=func_parse_options($v['options']);
}
}
// now that we have all the options and the javascript code we need to parse the names of the
// javascript functions and number them the same way the forms and form elements on the template will be numbered.
// I'm not sure this is the best solution for this, but it was the only one I could think of.
for($i=0;$i<count($products);$i++){
for($j=0;$j<count($products[$i]['product_options']);$j++){
$javascript=$products[$i]['product_options'][$j]['javascript_code'];
$pattern="/product_option/i";
$replacement="product_option_".$i."_".$j;
$new_javascript=preg_replace($pattern,$replacement,$javascript);
$products[$i]['product_options'][$j]['javascript_code']=$new_javascript;
//echo $replacement;
}
}
//-----END Product Options Mod by Brett Brewer
$smarty->assign("products",$products);
$smarty->assign("navigation_script","home.php?cat=$cat");
?>