sort order the shopping cart
#1
Posted 05 December 2011 - 11:05 PM
I can’t find out how to do in the forum. I use 2.3.1.
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#2
Posted 06 December 2011 - 08:28 AM
#3
Posted 06 December 2011 - 09:02 AM
Your search results also allow customers to sort by price .. this is the closest Ive found so far that is ok
#4
Posted 06 December 2011 - 06:28 PM
themuir, on 06 December 2011 - 09:02 AM, said:
Your search results also allow customers to sort by price .. this is the closest Ive found so far that is ok
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#5
Posted 06 December 2011 - 10:56 PM
Monika
addicted to writing code ... can't get enough of databases either, LOL!
my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum
Interactive Media Award July 2007 ~ category E-Commerce
my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
#6
Posted 07 December 2011 - 06:04 PM
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#7
Posted 08 December 2011 - 08:58 AM
for the attributes, the query is directly in the shopping_cart.php root file, so you can add sorting by name there.
Monika
addicted to writing code ... can't get enough of databases either, LOL!
my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum
Interactive Media Award July 2007 ~ category E-Commerce
my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
#8
Posted 09 December 2011 - 12:30 AM
$products_array = array();
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'ORDER BY p.products_id");
if ($products = tep_db_fetch_array($products_query)) {
$prid = $products['products_id'];
$products_price = $products['products_price'];
$any_out_of_stock = 0;
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
while (list($option, $value) = each($products[$i]['attributes'])) {
echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
where pa.products_id = '" . (int)$products[$i]['id'] . "'
and pa.options_id = '" . (int)$option . "'
and pa.options_id = popt.products_options_id
and pa.options_values_id = '" . (int)$value . "'
and pa.options_values_id = poval.products_options_values_id
and popt.language_id = '" . (int)$languages_id . "'
and poval.language_id = '" . (int)$languages_id . "'ORDER BY popt.products_options_name");
$attributes_values = tep_db_fetch_array($attributes);
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#9
Posted 09 December 2011 - 07:28 AM
function get_products() {
global $languages_id;
if (!is_array($this->contents)) return false;
$products_array = array();
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
if ($products = tep_db_fetch_array($products_query)) {
$prid = $products['products_id'];
$products_price = $products['products_price'];
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
if (tep_db_num_rows($specials_query)) {
$specials = tep_db_fetch_array($specials_query);
$products_price = $specials['specials_new_products_price'];
}
$products_array[] = array('id' => $products_id,
'name' => $products['products_name'],
'model' => $products['products_model'],
'image' => $products['products_image'],
'price' => $products_price,
'quantity' => $this->contents[$products_id]['qty'],
'weight' => $products['products_weight'],
'final_price' => ($products_price + $this->attributes_price($products_id)),
'tax_class_id' => $products['products_tax_class_id'],
'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
}
}
return $products_array;
Monika
addicted to writing code ... can't get enough of databases either, LOL!
my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum
Interactive Media Award July 2007 ~ category E-Commerce
my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
#10
Posted 09 December 2011 - 09:40 AM
in get_products() method (catalog/includes/classes/shopping_cart.php), reverse two keys :
$products_array[] = array('id' => $products_id,
'name' => $products['products_name'],
becomes
$products_array[] = array('name' => $products['products_name'],
'id' => $products_id,
and add in catalog/shopping_cart.php after :
<?php $any_out_of_stock = 0; $products = $cart->get_products();
this line :
sort($products);
#11
Posted 09 December 2011 - 09:05 PM
foxp2, on 09 December 2011 - 09:40 AM, said:
in get_products() method (catalog/includes/classes/shopping_cart.php), reverse two keys :
$products_array[] = array('id' => $products_id,
'name' => $products['products_name'],
becomes
$products_array[] = array('name' => $products['products_name'],
'id' => $products_id,
and add in catalog/shopping_cart.php after :
<?php $any_out_of_stock = 0; $products = $cart->get_products();
this line :
sort($products);
only problem is that it sort like this
01 option
10 option
18 option
02 option
24 option
25 option
26 option
03 option
04 option
05 option
06 option
not
01 option
02 option
03 option
04 option
05 option
06 option
10 option
18 option
24 option
25 option
26 option
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#12
Posted 10 December 2011 - 09:13 PM
01 option
10 option
11 option
12 option
(13-18 comes here)
19 option
02 option
20 option
21 option
03 option
04 option
05 option
06 option
07 option
08 option
09 option
but I want it to be like this
01 option
02 option
03 option
04 option
05 option
06 option
07 option
08 option
09 option
10 option
11 option
12 option
etc.
I tryed many thinks but without luck, I think it is in this code but how to do?
<?php
$any_out_of_stock = 0;
$products = $cart->get_products();
sort($products);
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
while (list($option, $value) = each($products[$i]['attributes'])) {
echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
where pa.products_id = '" . (int)$products[$i]['id'] . "'
and pa.options_id = '" . (int)$option . "'
and pa.options_id = popt.products_options_id
and pa.options_values_id = '" . (int)$value . "'
and pa.options_values_id = poval.products_options_values_id
and popt.language_id = '" . (int)$languages_id . "'
and poval.language_id = '" . (int)$languages_id . "'");
$attributes_values = tep_db_fetch_array($attributes);
$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
$products[$i][$option]['options_values_id'] = $value;
$products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
$products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
$products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
}
}
}
?>
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#13
Posted 10 December 2011 - 11:09 PM
peteravu, on 10 December 2011 - 09:13 PM, said:
I tryed many thinks but without luck, I think it is in this code but how to do?
.../...
attributes are ordered in product_info.php file :
line 151:
Quote
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
:
#14
Posted 11 December 2011 - 01:14 AM
foxp2, on 10 December 2011 - 11:09 PM, said:
attributes are ordered in product_info.php file :
line 151:
but your modifications have broken this logic : http://forums.oscomm...07#entry1613107
:
well this modification are made by Separate Pricing Per Customer. What to replace it with?
(int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
I try this the 2 places but still sort the same way.
// $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
also I try replace the product_info.php with the original one, but still sort 1-10-11-12-19-02-20-21-03-04-05
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#15
Posted 11 December 2011 - 08:52 AM
(int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
with :
(int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by ABS(popt.products_options_name) ASC");
and give me the result.?
#16
Posted 11 December 2011 - 10:43 AM
without order by ABS :
http://echoscystem.c...&products_id=30
with order by ABS :
http://echoscystem.c...&products_id=29
ref : http://dev.mysql.com...timization.html
Edited by foxp2, 11 December 2011 - 10:45 AM.
#17
Posted 11 December 2011 - 01:45 PM
so this is my last attempt on line 182, 237 and 307
I also tried with = 0 order by pov.products_options_values_name");
but still the same result
<?php
/*
$Id$
adapted for Separate Pricing Per Customer v4.2 2007/06/23
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);
$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_check = tep_db_fetch_array($product_check_query);
// BOF Separate Pricing per Customer
if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
} else {
$customer_group_id = '0';
}
// EOF Separate Pricing per Customer
require(DIR_WS_INCLUDES . 'template_top.php');
if ($product_check['total'] < 1) {
?>
<div class="contentContainer">
<div class="contentText">
<?php echo TEXT_PRODUCT_NOT_FOUND; ?>
</div>
<div style="float: right;">
<?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?>
</div>
</div>
<?php
} else {
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);
tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
// BOF Separate Pricing per Customer
if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id = '" . $customer_group_id . "'");
if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
$product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
} // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer
$products_price = '<del>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
// BOF Separate Pricing per Customer
if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id = '" . $customer_group_id . "'");
if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
$product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
} // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer
$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}
if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '<br /><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
$products_name = $product_info['products_name'];
}
?>
<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>
<div>
<style="float: right;"><?php echo $products_price; ?>
<h1><?php echo $products_name; ?></h1>
</div>
<div class="contentContainer">
<div class="contentText">
<?php
if (tep_not_null($product_info['products_image'])) {
$pi_query = tep_db_query("select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order");
if (tep_db_num_rows($pi_query) > 0) {
?>
<div id="piGal" style="float: right;">
<ul>
<?php
$pi_counter = 0;
while ($pi = tep_db_fetch_array($pi_query)) {
$pi_counter++;
$pi_entry = ' <li><a href="';
if (tep_not_null($pi['htmlcontent'])) {
$pi_entry .= '#piGalimg_' . $pi_counter;
} else {
$pi_entry .= tep_href_link(DIR_WS_IMAGES . $pi['image']);
}
$pi_entry .= '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $pi['image']) . '</a>';
if (tep_not_null($pi['htmlcontent'])) {
$pi_entry .= '<div style="display: none;"><div id="piGalimg_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div></div>';
}
$pi_entry .= '</li>';
echo $pi_entry;
}
?>
</ul>
</div>
<script type="text/javascript">
$('#piGal ul').bxGallery({
maxwidth: 300,
maxheight: 200,
thumbwidth: <?php echo (($pi_counter > 1) ? '75' : '0'); ?>,
thumbcontainer: 300,
load_image: 'ext/jquery/bxGallery/spinner.gif'
});
</script>
<?php
} else {
?>
<div id="piGal" style="float: right;">
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank" rel="fancybox">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), null, null, 'hspace="5" vspace="5"') . '</a>'; ?>
</div>
<?php
}
?>
<script type="text/javascript">
$("#piGal a[rel^='fancybox']").fancybox({
cyclic: true
});
</script>
<?php
}
?>
<?php echo stripslashes($product_info['products_description']); ?>
<?php
// BOF SPPC Hide attributes from customer groups
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<!--
// Code segment includes/modified for Multiple product option lines.
// maintainance and Qns : Harishyam :> feenix_666@yahoo.com
-->
<?php
if ($products_options_total['total'] == 1) {
for($i=0;$i<$products_attributes['total'];$i++)
{
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
$products_options_array = array();
$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by ABS(pov.products_options_values_name) ASC");
$list_of_prdcts_attributes_id = '';
$products_options = array(); // makes sure this array is empty again
while ($_products_options = tep_db_fetch_array($products_options_query)) {
$products_options[] = $_products_options;
$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}
if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') {
$select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
$pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
while ($pag_array = tep_db_fetch_array($pag_query)) {
$cg_attr_prices[] = $pag_array;
}
// substitute options_values_price and prefix for those for the customer group (if available)
if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
for ($n = 0 ; $n < count($products_options); $n++) {
for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
}
} // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
}
} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
} // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
for ($n = 0 ; $n < count($products_options); $n++) {
$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
if ($products_options[$n]['options_values_price'] != '0') {
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
}
}
// EOF SPPC attributes mod
if (is_string($HTTP_GET_VARS['products_id']) && isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
$selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
} else {
$selected_attribute = false;
}
?>
<?php
$count = 1;
$maxPerList = 15;
$total = $products_attributes['total'];
if ($products_options_total['total'] == 1) {
echo "<ul style='float:left;'>"; //Start list
for($i=0;$i<$products_attributes['total'];$i++) {
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
$products_options_array = array();
$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by ABS(pov.products_options_values_name) ASC");
$list_of_prdcts_attributes_id = '';
$products_options = array(); // makes sure this array is empty again
while ($_products_options = tep_db_fetch_array($products_options_query)) {
$products_options[] = $_products_options;
$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}
if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') {
$select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
$pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
while ($pag_array = tep_db_fetch_array($pag_query)) {
$cg_attr_prices[] = $pag_array;
}
// substitute options_values_price and prefix for those for the customer group (if available)
if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
for ($n = 0 ; $n < count($products_options); $n++) {
for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
}
} // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
}
} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
} // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
for ($n = 0 ; $n < count($products_options); $n++) {
$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
if ($products_options[$n]['options_values_price'] != '0') {
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
}
}
if (is_string($HTTP_GET_VARS['products_id']) && isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
$selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
} else {
$selected_attribute = false;
}
echo '<li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">';
echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];
echo "</li>";
if ($count % $maxPerList == 0 && $count != $total) { //Check if remainder is 0 or if it is the last product
echo "</ul><ul style='float:left; padding-left: 10px;'>"; ///Close list and start a new one
}
$count++;
}
} // End of loop
echo "</ul>"; //Close any left open tag
}
}
}} else {
//do your regular thing
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
$products_options_array = array();
$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by 0 order by ABS(pov.products_options_values_name) ASC");
while ($products_options = tep_db_fetch_array($products_options_query)) {
$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
if ($products_options['options_values_price'] != '0') {
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
}
}
if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
$selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
} else {
$selected_attribute = false;
}
}
?>
<strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br />
<?php
}
?>
</p>
<?php
}
?>
<div style="clear: both;"></div>
<?php
if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
<p style="text-align: center;"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></p>
<?php
}
?>
</div>
<?php
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and reviews_status = 1");
$reviews = tep_db_fetch_array($reviews_query);
?>
<div class="buttonSet" style="float:left">
<span class="buttonAction"><?php if ($products_options_total['total'] != 1) { echo 'Enter Quantity: ' . tep_draw_input_field('cart_quantity','1','size="3" style="text-align:right;"') . ' ' ; } ?>
<?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>
</div>
<?php
if ((USE_CACHE == 'true') && empty($SID)) {
echo tep_cache_also_purchased(3600);
} else {
include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
?>
</div>
</form>
<?php
}
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#18
Posted 12 December 2011 - 06:23 PM
foxp2, on 10 December 2011 - 11:09 PM, said:
attributes are ordered in product_info.php file :
line 151:
but your modifications have broken this logic : http://forums.oscomm...07#entry1613107
:
Forum, Thanks Designing New Themes the Easy Way, how-to-set-backgrounds.
my contributions Add Multiple Product In Product Listing 2.3.1 v.1.0 and Multiple Attribute entry boxes in product info page v1.0 for 2.3.1
#19
Posted 12 December 2011 - 06:51 PM
Monika
addicted to writing code ... can't get enough of databases either, LOL!
my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum
Interactive Media Award July 2007 ~ category E-Commerce
my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
#20
Posted 12 December 2011 - 07:54 PM
peteravu, on 12 December 2011 - 06:23 PM, said:
but I'll wait for monica's solution.
my code works :
if($product_info['products_id'] == 29) {
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by ABS(popt.products_options_name) ASC");
}else{
$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
}
Edited by foxp2, 12 December 2011 - 07:57 PM.









