Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi there,

 

Not a coding expert - please be patient...

 

I've spent days working on this, but somehow I'm unable to get my Shop by Price installation to display properly.

Managed to get it to function properly, but my results are displayed above my template heading and rest of the page.

Please see this link:

 

I would appreciate any guidance as to how to solve this. I'm posting the relevant coding below - please let me know

if you require more files.

 

My catalog/shop_by_price.php:

 

<?php

/*

$Id: shop_by_price.php 3 2006-05-27 04:59:07Z user $

 

osCMax Power E-Commerce

http://oscdox.com

 

Copyright 2006 osCMax

 

Released under the GNU General Public License

*/

 

// Most of this file is changed or moved to BTS - Basic Template System - format.

// For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

// catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

// (Sub 'fallback' with your current template to see if there is a template specific file.)

 

require('includes/application_top.php');

 

// I suppose next line is to work with STS, no need for the others, you can leave it or remove it.

$sbprice = true;

 

// Initialize the varaible '$range' from param here because it's used in FILENAME_SHOP_BY_PRICE

$range = 0;

if (isset($HTTP_GET_VARS['range'])) {

$range = $HTTP_GET_VARS['range'];

}

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOP_BY_PRICE);

 

$pfrom = isset($price_min[$range]) ? $price_min[$range] : 0;

$pto = isset($price_max[$range]) ? $price_max[$range] : 0;

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOP_BY_PRICE, tep_get_all_get_params(), 'NONSSL', true, false));

 

 

// create column list

 

$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,

 

'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,

 

'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,

 

'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,

 

'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,

 

'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,

 

'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,

 

// Product Listing in Columns - Start (You can remove those 4 lines if you are not using it).

 

'PRODUCT_LIST_MULTIPLE' => PRODUCT_LIST_MULTIPLE,

 

'PRODUCT_LIST_BUY_NOW_MULTIPLE' => PRODUCT_LIST_BUY_NOW_MULTIPLE,

 

// Product Listing in Columns - End

 

'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

 

 

 

asort($define_list);

 

 

 

$column_list = array();

 

reset($define_list);

 

while (list($key, $value) = each($define_list)) {

 

if ($value > 0) $column_list[] = $key;

 

}

 

 

 

$select_column_list = '';

 

 

 

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

 

switch ($column_list[$i]) {

 

case 'PRODUCT_LIST_MODEL':

 

$select_column_list .= 'p.products_model, ';

 

break;

 

case 'PRODUCT_LIST_MANUFACTURER':

 

$select_column_list .= 'm.manufacturers_name, ';

 

break;

 

case 'PRODUCT_LIST_QUANTITY':

 

$select_column_list .= 'p.products_quantity, ';

 

break;

 

case 'PRODUCT_LIST_IMAGE':

 

$select_column_list .= 'p.products_image, ';

 

break;

 

case 'PRODUCT_LIST_WEIGHT':

 

$select_column_list .= 'p.products_weight, ';

 

break;

 

}

 

}

 

 

 

$select_str = "select distinct " . $select_column_list . " p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price ";

 

 

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

 

$select_str .= ", SUM(tr.tax_rate) as tax_rate ";

 

}

 

 

 

$from_str = "from (" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id";

 

 

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

 

if (!tep_session_is_registered('customer_country_id')) {

 

$customer_country_id = STORE_COUNTRY;

 

$customer_zone_id = STORE_ZONE;

 

}

 

$from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";

 

}

 

 

 

$from_str .= ", " . TABLE_PRODUCTS_DESCRIPTION . " pd";

 

 

 

$where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";

 

 

 

if (DISPLAY_PRICE_WITH_TAX == 'true') {

 

if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")";

 

if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")";

 

} else {

 

if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")";

 

if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")";

 

}

 

 

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

 

$where_str .= " group by p.products_id, tr.tax_priority";

 

}

 

 

 

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {

 

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

 

if ($column_list[$i] == 'PRODUCT_LIST_PRICE') {

 

$HTTP_GET_VARS['sort'] = $i+1 . 'a';

 

$order_str = ' order by final_price, pd.products_name';

 

break;

 

}

 

}

 

} else {

 

$sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);

 

$sort_order = substr($HTTP_GET_VARS['sort'], 1);

 

$order_str = ' order by ';

 

switch ($column_list[$sort_col-1]) {

 

case 'PRODUCT_LIST_MODEL':

 

$order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

 

break;

 

case 'PRODUCT_LIST_NAME':

 

$order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : "");

 

break;

 

case 'PRODUCT_LIST_MANUFACTURER':

 

$order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

 

break;

 

case 'PRODUCT_LIST_QUANTITY':

 

$order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

 

break;

 

case 'PRODUCT_LIST_IMAGE':

 

$order_str .= "pd.products_name";

 

break;

 

case 'PRODUCT_LIST_WEIGHT':

 

$order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

 

break;

 

case 'PRODUCT_LIST_PRICE':

 

$order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name";

 

break;

 

}

 

}

 

 

 

$listing_sql = $select_str . $from_str . $where_str . $order_str;

 

 

 

require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING);

 

?>

 

</td>

 

</tr>

 

</table></td>

 

<!-- body_text_eof //-->

 

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

 

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

 

<?php

 

include (bts_select('main', $content_template)); // BTSv1.5

 

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

 

Herewith the coding for my catalog/templates/templatename/content/shop_by_price.tpl.php:

 

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<html <?php echo HTML_PARAMS; ?>>

 

<head>

 

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

 

<title><?php echo TITLE; ?></title>

 

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">

 

<link rel="stylesheet" type="text/css" href="stylesheet.css">

 

</head>

 

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td>

<?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

 

<?php echo tep_draw_form('shop_by_price', tep_href_link(FILENAME_SHOP_BY_PRICE, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

</tr>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td>

<?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

 

<?php echo tep_draw_form('shop_by_price', tep_href_link(FILENAME_SHOP_BY_PRICE, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

</tr>

 

<!-- body //-->

 

<table border="0" width="100%" cellspacing="3" cellpadding="3">

 

<tr>

 

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

 

</table></td>

 

</td>

 

</tr>

 

</table></td>

 

<!-- body_text_eof //-->

 

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

 

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<?php

?>

 

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Thank you!

Charene

Charene

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...