crashwave Posted October 17, 2005 Share Posted October 17, 2005 (edited) I tried this contribution for a hour or so and no joy. The instructions are BAD ! what files am i supposed to alter and what am i supposed to delete? People here talkin about the orders.php but i never saw an instruction to alter that! After a lot of messin around i found this one: http://www.oscommerce.com/community/contributions,2487 Way way way simpler, one mod in one file (it tells you the name of the file to change on the contrib page) and it seems to be working. Anyone have clearer instuctions on this one? and will it actually do anything better/different? Ian Maybe if it is read correctly people will get it. It clearly states what files to modify CLASS/SHOPPING_CART.PHP1-Under 3-To display '0' values change this in Product_info.php (Or product_info.tpl.php for template/loaded) 5-in classes/shopping_cart.php above and the order.php 9--In Classes/order.php Change http://www.dailywholesale.com/creloaded/Ad...rices_1.41.html Edited October 17, 2005 by crashwave Quote q_|_|| _|9~~J >-o>-o q_|_|| )| q_|| ) Link to comment Share on other sites More sharing options...
crashwave Posted October 17, 2005 Share Posted October 17, 2005 (edited) For those that have a problem finding the file names I highlighted them. All it is is cut and paste. If you think it is horrible..Use something else, or make your own the way you like it. there are people using this on live sites. Can any 1 help me on this ....followed instrustions i downloaded from here ...... http://www.dailywholesale.com/creloaded/Ad...rices_1.41.html.i get this ...... Parse error: parse error, unexpected ';', expecting ')' in /home/*******/public_html/catalog/includes/classes/shopping_cart.php on line 299 This is the code i copied of the above file ............. 5-in classes/shopping_cart.php above $products_array[] = array('id' => $products_i add //BOF PHPMOM.COM AAP//hadir $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '') { $attributes_price += ($attribute_price['options_values_price']-$products_price); } elseif ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } elseif ($attribute_price['price_prefix'] == '-') { $attributes_price -= $attribute_price['options_values_price']; } } } //eof actual attribute//hadir ---------------------------------------------------------------------------------------------------- And replaced this in the shopping cart.php ................................ $products_array[] = array('id' => $products_id, SHOULD THE CODE GO HERE NO 5-in classes/shopping_cart.php above $products_array[] = array('id' => $products_i add //BOF PHPMOM.COM AAP//hadir $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '') { $attributes_price += ($attribute_price['options_values_price']-$products_price); } elseif ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } elseif ($attribute_price['price_prefix'] == '-') { $attributes_price -= $attribute_price['options_values_price']; } } } //eof actual attribute//hadir It says above Edited October 17, 2005 by crashwave Quote q_|_|| _|9~~J >-o>-o q_|_|| )| q_|| ) Link to comment Share on other sites More sharing options...
Irin Posted October 20, 2005 Share Posted October 20, 2005 Hello, I have just one question: how can I add "each" to the price value (Ex.: $50.00 each)? Thanks in advance. Irina. Quote Link to comment Share on other sites More sharing options...
crashwave Posted October 20, 2005 Share Posted October 20, 2005 Each is a given I think when someone orders. You will have to change table structure to accept text. also the attribute page price options will have to be changed to allow other than number I think. $x has to be a whole number not $x.50 Where price is called it needs to be changed to (int)$attribute_price (where attribute_price is the price name don't remember exact name off the top of my head). ie you need to add (int) everytime attribute price is requested or assign it like $attribute_price = (int)$attribute_price (also account for currency class) with 50 each that will output 50 Quote q_|_|| _|9~~J >-o>-o q_|_|| )| q_|| ) Link to comment Share on other sites More sharing options...
nprzybilla Posted October 26, 2005 Share Posted October 26, 2005 Hi, tried the contrib.Looks great. But I have the problem with easypopulate. EasyPopulate adds + signs to the attributes. I did not managed to manupulate the easypopulate.php like mentioned on page four of this thread. I have easypopulate 2.76b. Has anyone installed these both contributions together ? Best regards Niels Quote Link to comment Share on other sites More sharing options...
Irin Posted October 26, 2005 Share Posted October 26, 2005 Each is a given I think when someone orders.You will have to change table structure to accept text. also the attribute page price options will have to be changed to allow other than number I think. $x has to be a whole number not $x.50 Where price is called it needs to be changed to (int)$attribute_price (where attribute_price is the price name don't remember exact name off the top of my head). ie you need to add (int) everytime attribute price is requested or assign it like $attribute_price = (int)$attribute_price (also account for currency class) with 50 each that will output 50 Hello, crashwave. Could you please explain me step by step how can I add "each" to the price value in products attributes dropdown box? I'm lost. I'll really appreciate your help. Thanks in advance. Irina. Quote Link to comment Share on other sites More sharing options...
parsonsd Posted November 5, 2005 Share Posted November 5, 2005 Well This is really what I am looking for but I can not get it to work I have been at this for about 4 hours trying over and over again with no luck. Need Help. Thanks Quote Link to comment Share on other sites More sharing options...
petsk Posted November 19, 2005 Share Posted November 19, 2005 Hi, I use the QTPro contribution, is it possible to use Actual Attribute Price whit this contribution? :) Best wishes, Peter Quote Link to comment Share on other sites More sharing options...
Andreas2003 Posted November 21, 2005 Share Posted November 21, 2005 Hi there, first of all, this is the contribution I was looking for. Thanks for it. But I have a problem. I installed it like the instructions, and it seems for a second to work. But as I refreshed my site, I received an error message from my other contribution "supertracker", you find it here: Fatal error: Call to undefined function: show_total() in /***/***/***/htdocs/includes/classes/supertracker.php on line 135 Seems to be that something is messing around. Here is the code of my shopping cart.php, I took the "simple" way of displaying the attribute price: <?php /* $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$option] = $value; // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } $this->cleanup(); // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function update_quantity($products_id, $quantity = '', $attributes = '') { global $customer_id; if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true.. $this->contents[$products_id] = array('qty' => $quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id]['attributes'][$option] = $value; // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } } } function cleanup() { global $customer_id; reset($this->contents); while (list($key,) = each($this->contents)) { if ($this->contents[$key]['qty'] < 1) { unset($this->contents[$key]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); } } } } function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $total_items += $this->get_quantity($products_id); } } return $total_items; } function get_quantity($products_id) { if (isset($this->contents[$products_id])) { return $this->contents[$products_id]['qty']; } else { return 0; } } function in_cart($products_id) { if (isset($this->contents[$products_id])) { return true; } else { return false; } } function remove($products_id) { global $customer_id; unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function remove_all() { $this->reset(); } function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_list .= ', ' . $products_id; } } return substr($product_id_list, 2); } function calculate() { $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; $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']; } $this->total += tep_add_tax($products_price, $products_tax) * $qty; // BOF contrib nr.1716 - Actual attribute price // $this->weight += ($qty * $products_weight); // } // phpmom.com advanced attribute price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } elseif ($attribute_price['price_prefix'] == '-') { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } elseif ($attribute_price['price_prefix'] == '') { //comment where you see //'0' if want '0' value // if ($attribute_price['options_values_price'] == '0') { //'0' // $this->total += 0; //'0' // } //'0' // if ($attribute_price['options_values_price'] != '0') { //'0' $this->total += tep_add_tax($attribute_price['options_values_price'], $products_tax) * $qty - (tep_add_tax($products_price, $products_tax) * $qty); // }//'0' }else $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } } // EOF contrib nr.1716 - Actual attribute price // attributes price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } } } } } // BOF contrib nr.1716 - Actual attribute price // function attributes_price($products_id) { // $attributes_price = 0; // if (isset($this->contents[$products_id]['attributes'])) { // reset($this->contents[$products_id]['attributes']); // while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { // $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); // $attribute_price = tep_db_fetch_array($attribute_price_query); // if ($attribute_price['price_prefix'] == '+') { // $attributes_price += $attribute_price['options_values_price']; // } else { // $attributes_price -= $attribute_price['options_values_price']; // } // } // } // return $attributes_price; // } //PHPMOM.COM AAP function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } elseif ($attribute_price['price_prefix'] == '-') { $attributes_price -= $attribute_price['options_values_price']; } else $attributes_price+= $attribute_price['options_values_price']; } } return $attributes_price; } //BOF PHPMOM.COM AAP function attributes_prefix($products_id) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_prefix_query = tep_db_query("select price_prefix from ". TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id ."' and options_id = '" . (int)$option . "' and options_values_id = '" .(int)$value . "'"); $attribute_prefix = tep_db_fetch_array($attribute_prefix_query); $attributes_prefix = $attribute_prefix['price_prefix']; } } return $attributes_prefix; }//eof aap // EOF contrib nr.1716 - Actual attribute price 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']; } // BOF contrib nr.1716 - Actual attribute price //BOF PHPMOM.COM AAP//hadir if (isset($this->contents[$products_id]['attributes'])) { if ($this->attributes_prefix($products_id) == ''){ $the_final_price = $this->attributes_price($products_id); } else $the_final_price = ($products_price + $this->attributes_price($products_id)); }else $the_final_price = ($products_price); //eof actual attribute//hadir // EOF contrib nr.1716 - Actual attribute 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'], // BOF contrib nr.1716 - Actual attribute price // 'final_price' => ($products_price + $this->attributes_price($products_id)), 'final_price' => $the_final_price, //PHPMOM.COM AAP // EOF contrib nr.1716 - Actual attribute price 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); } } return $products_array; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } } } ?> And here is the code of the supertracker contribution : <?php /* $Id: supertracker.php,v3.1 2005/10/22 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class supertracker { function supertracker(){ } function update() { global $cart, $HTTP_GET_VARS, $customer_id; //// **** CONFIGURATION SECTION **** //// //Comma Separate List of IPs which should not be recorded, for instance, your own PCs IP address, or //that of your server if you are using Cron Jobs, etc $excluded_ips = ''; //// **** CONFIGURATION SECTION EOF **** //// $record_session = true; $ip_address = $_SERVER['REMOTE_ADDR']; if ($excluded_ips != '') { $ex_array = explode(',',$excluded_ips); foreach ($ex_array as $key => $ex_ip) { if ($ip_address == $ex_ip) $record_session = false; } } //Big If statement that stops us doing anything more if this IP is one of the //ones we have chosen to exclude if ($record_session) { $existing_session = false; $thirty_ago_timestamp = strtotime("now") - (30*60); $thirty_mins_ago = date('Y-m-d H:i:s', $thirty_ago_timestamp); $browser_string = $_SERVER['HTTP_USER_AGENT']; $ip_array = explode ('.',$ip_address); $ip_start = $ip_array[0] . '.' . $ip_array[1]; //Find out if this user already appears in the supertracker db table //First thing to try is customer_id, if they are signed in if (isset($customer_id)) { $query = "select * from supertracker where customer_id ='" . $customer_id . "' and last_click > '" . $thirty_mins_ago . "'"; $result = tep_db_query($query); if (tep_db_num_rows ($result) > 0) { $existing_session = true; } } //Next, we try this: compare first 2 parts of the IP address (Class B), and the browser //Identification String, which give us a good chance of locating the details for a given user. I reckon //that the chances of having more than 1 user within a 30 minute window with identical values //is pretty small, so hopefully this will work and should be more reliable than using Session IDs.... if (!$existing_session) { $query = "select * from supertracker where browser_string ='" . $browser_string . "' and ip_address like '" . $ip_start . "%' and last_click > '" . $thirty_mins_ago . "'"; $result = tep_db_query($query); if (tep_db_num_rows ($result) > 0) { $existing_session = true; } } //If that didn't work, and we have something in the cart, we can use that to try and find the //record instead. Obviously, people with things in their cart don't just appear from nowhere! if (!$existing_session) { if ($cart->count_contents()>0) { $query = "select * from supertracker where cart_total ='" . $cart->show_total() . "' and last_click > '" . $thirty_mins_ago . "'"; $result = tep_db_query($query); if (tep_db_num_rows ($result) > 0) { $existing_session = true; } } } //Having worked out if we have a new or existing user session lets record some details....! if ($existing_session) { //Existing tracked session, so just update relevant existing details $tracking_data = tep_db_fetch_array($result); $tracking_id = $tracking_data['tracking_id']; $products_viewed=$tracking_data['products_viewed']; $added_cart = $tracking_data['added_cart']; $completed_purchase = $tracking_data['completed_purchase']; $num_clicks = $tracking_data['num_clicks']+1; $categories_viewed = unserialize($tracking_data['categories_viewed']); $cart_contents = unserialize($tracking_data['cart_contents']); $cart_total = $tracking_data['cart_total']; $order_id = $tracking_data['order_id']; if (isset($customer_id)) $cust_id=$customer_id; else $cust_id=$tracking_data['customer_id']; $current_page=$_SERVER['PHP_SELF']; $last_click = date('Y-m-d H:i:s'); //Find out if the customer has added something to their cart for the first time if (($added_cart!='true') && ($cart->count_contents()>0)) $added_cart = 'true'; //Has a purchase just been completed? if ((strstr($current_page, 'checkout_success.php'))&& ($completed_purchase!='true')) { $completed_purchase='true'; $order_q = "select orders_id from orders where customers_id = '" . $cust_id . "' ORDER BY date_purchased DESC"; $order_result = tep_db_query($order_q); if (tep_db_num_rows($order_result) > 0) { $order_row = tep_db_fetch_array($order_result); $order_id = $order_row['orders_id']; } } //If customer is looking at a product, add it to the list of products viewed if (strstr($current_page, 'product_info.php')) { $current_product_id = $HTTP_GET_VARS['products_id']; if (!strstr($products_viewed, '*' . $current_product_id . '?')) { //Product hasn't been previously recorded as viewed $products_viewed .= '*' . $current_product_id . '?'; } } //Store away their cart contents //But, the cart is dumped at checkout, so we don't want to overwrite the stored cart contents //In this case $current_cart_contents = serialize($cart->contents); if (strlen($current_cart_contents)>6) { $cart_contents = $current_cart_contents; $cart_total = $cart->show_total(); } //If we are on index.php, but looking at category results, make sure we record which category if (strpos($current_page, 'index.php')) { if (isset($_GET['cPath'])) { $cat_id = $_GET['cPath']; $cat_id_array = explode('_',$cat_id); $cat_id = $cat_id_array[sizeof($cat_id_array)-1]; $categories_viewed[$cat_id]=1; } } $categories_viewed = serialize($categories_viewed); $query = "UPDATE supertracker set last_click='" . $last_click . "', exit_page='" . $current_page . "', num_clicks='" . $num_clicks . "', added_cart='" . $added_cart . "', categories_viewed='" . $categories_viewed . "', products_viewed='" . $products_viewed . "', customer_id='" . $cust_id . "', completed_purchase='" . $completed_purchase . "', cart_contents='" . $cart_contents . "', cart_total = '" . $cart_total . "', order_id = '" . $order_id . "' where tracking_id='" . $tracking_id . "'"; tep_db_query($query); } else { //New vistor, so record referrer, etc //Next line defines pages on which a new visitor should definitely not be recorded $prohibited_pages = 'login.php,checkout_shipping.php,checkout_payment.php,checkout_process.php,ch eckout_confirmation.php,checkout_success.php'; $current_page=$_SERVER['PHP_SELF']; if (!strpos($prohibited_pages, $current_page)) { $refer_data = $_SERVER['HTTP_REFERER']; $refer_data = explode('?', $refer_data); $referrer=$refer_data[0]; $query_string=$refer_data[1]; $ip = $_SERVER['REMOTE_ADDR']; $browser_string = $_SERVER['HTTP_USER_AGENT']; include(DIR_WS_INCLUDES . "geoip.inc"); $gi = geoip_open(DIR_WS_INCLUDES . "GeoIP.dat",GEOIP_STANDARD); $country_name = geoip_country_name_by_addr($gi, $ip); $country_code = strtolower(geoip_country_code_by_addr($gi, $ip)); geoip_close($gi); $time_arrived = date('Y-m-d H:i:s'); $landing_page = $_SERVER['REQUEST_URI']; $query = "INSERT INTO `supertracker` (`ip_address`, `browser_string`, `country_code`, `country_name`, `referrer`,`referrer_query_string`,`landing_page`,`exit_page`,`time_arrived`,`last_click`) VALUES ('" . $ip . "','" . $browser_string . "','" . $country_code . "', '" . $country_name . "', '" . $referrer . "', '" . $query_string . "','" . $landing_page . "','" . $current_page . "','" . $time_arrived . "','" . $time_arrived . "')"; tep_db_query($query); }//end if for prohibited pages }//end else }//End big If statement (Record Exclusion for certain IPs) }//End function update }//End Class ?> Can you please be so kind and give me advise, what to change, that your great contribution is running also with supertracker ? Unfortunately, I cannot review the code by myself. Thank you very much, I appreciate all your help, kind regards and sorry for the long posting, Andreas Quote Link to comment Share on other sites More sharing options...
Andreas2003 Posted November 23, 2005 Share Posted November 23, 2005 So, I have an update. Supertracker has an entry in the application_top.php, so I commented these lines out, that supertracker.php is not required any more. But then I get a new error message, when I want to place an item in the cart: Call to undefined function: get_products() in /***/***/catalog/includes/boxes/shopping_cart.php on line 25 In the classes/shopping_cart.php in line 25, the function "insert current cart contents in DB" begins. Another error message was in same file, line 107 at function "assign a temporary unique ID to the order ....". Please advise what I have to change in order to get this to work. I'm totally stuck, so please be so kind and help me out. Thanks in advance, Regards Andreas Quote Link to comment Share on other sites More sharing options...
Guest Posted January 26, 2006 Share Posted January 26, 2006 I have a problem with shopping_cart.php classes and Specials Prices: When I add a product with Special Price and attribute price prefix empty and options_values_price=0 the shopingcart.php and boxes shopingcart.php dont work correctly because on subtotal use regular price, but checkout_confirmation.php work correctly. Thanks for you help Quote Link to comment Share on other sites More sharing options...
Qihun Posted February 21, 2006 Share Posted February 21, 2006 I tried to install this contribution for 2 days and I can't get it work . I am totally confused with "unstable" instructions (I am sorry) if I don't have the parse error , so i have zerros in my basket can some one post here modifaed files for fresh OSCommerce I will really appreciate this. Quote Link to comment Share on other sites More sharing options...
ATeschner Posted February 21, 2006 Share Posted February 21, 2006 I tried to install this contribution for 2 days and I can't get it work .I am totally confused with "unstable" instructions (I am sorry) if I don't have the parse error , so i have zerros in my basket can some one post here modifaed files for fresh OSCommerce I will really appreciate this. I am going to do that for you now. I think it is not very clear how this MOD works though. If you have a prefix in your price_prefix field, the calculation will behave as a default store. If there is no prefix, it will pass the flat price from options_values_price to the shopping cart. So if you have zero for the attribute and no prefix, you will be selling the item for nothing. If you put a + in the prefix field and a zero for the amount, your customer will be adding the option to the base price for no additional charge... if that makes sense... Check out the contrib page - I have cleaned up the instructions a bit and included "drop-in" files for those who prefer compare utilities for their modding. Cheers! :thumbsup: Quote Link to comment Share on other sites More sharing options...
Qihun Posted February 22, 2006 Share Posted February 22, 2006 Thank you Amber for your effort. I play with the files and still can't get desirable result. I found i still need to alter order files because i have order with zero total I am going to play with checkout. Do you have it works on your shop and did have problems with order_total? may be I altered somewhere and need to upload backup Thank you again for attention to this problem Miclosh Quote Link to comment Share on other sites More sharing options...
ATeschner Posted February 22, 2006 Share Posted February 22, 2006 Thank you Amber for your effort. I play with the files and still can't get desirable result. I found i still need to alter order files because i have order with zero total I am going to play with checkout. Do you have it works on your shop and did have problems with order_total? may be I altered somewhere and need to upload backup Thank you again for attention to this problem Miclosh Oooh. I see what you are saying. I don't have a live shop yet, I am just beginning to develop, and the total appeared to be correct in the shopping cart, but when I read your post, I tried to checkout and the wrong value is being passed to order_total. I will mess with it some more. Thanks - That might have evaded me for too long if you didn't point that out. Quote Link to comment Share on other sites More sharing options...
ATeschner Posted February 22, 2006 Share Posted February 22, 2006 I will mess with it some more. Well, I have been poking around and what seems to be the problem is that we changed the if/else statement in /includes/classes/shopping_cart.php to an if/elseif/else, but these changes in calculation should also be reflected in the module that calculates the subtotal for the order. The subtotal for the shopping cart is not passed directly to the order, the order does it's own calculation. I am not quite sure how the code works with all the arrays and stuff (I am only a self-taught novice :blush: ) but my focus has been drawn to the process() functions in /includes/modules/order_total/ot_subtotal.php, specifically: function process() { global $order, $currencies; $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format($order->info['subtotal'], true, $order->info['currency'], $order->info['currency_value']), 'value' => $order->info['subtotal']); } and in /includes/classes/order_total.php function process() { $order_total_array = array(); if (is_array($this->modules)) { reset($this->modules); while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled) { $GLOBALS[$class]->process(); for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) { if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) { $order_total_array[] = array('code' => $GLOBALS[$class]->code, 'title' => $GLOBALS[$class]->output[$i]['title'], 'text' => $GLOBALS[$class]->output[$i]['text'], 'value' => $GLOBALS[$class]->output[$i]['value'], 'sort_order' => $GLOBALS[$class]->sort_order); } } } } } return $order_total_array; } I believe this part of checkout_confirmation.php <?php if (MODULE_ORDER_TOTAL_INSTALLED) { $order_total_modules->process(); echo $order_total_modules->output(); } ?> is where the $order_total_array is returned to show the first sign of miscalculation in this MOD. Then upon continuing to checkout_process.php, the process function is called again require(DIR_WS_CLASSES . 'order_total.php'); $order_total_modules = new order_total; $order_totals = $order_total_modules->process(); and later actually places the values in the database by this code: for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) { $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']); tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); } ...So I can get as far as interpreting the code but am not sure how arrays work. But I thought maybe I could give someone else a lead on this. I feel that the problem mostly lies in the process() function in ot_subtotal.php or order_total.php I need this to work too but am spending too much time on it at the moment. If nobody else pops up with an idea I will pick it up when my store is further along. Sorry I couldn't be more help right now. Quote Link to comment Share on other sites More sharing options...
Qihun Posted February 23, 2006 Share Posted February 23, 2006 I can't get it work with last updates for this contribution ( sorry ) I rolled back to version 1.2.2 and it seems to be ok on my shop (localhost clean) I post here two files from last OSC version with addition of AAP 1.2.2 1. classes/shopping_cart.php 2.function/general.php I didn't change anything inside BOF AAP-----EOF AAP 1.2.2 all credits and many thanks go to all people who made it for us <?php /* $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) { $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); if (is_numeric($products_id) && is_numeric($qty)) { $check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $check_product = tep_db_fetch_array($check_product_query); if (($check_product !== false) && ($check_product['products_status'] == '1')) { if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id_string)) { $this->update_quantity($products_id_string, $qty, $attributes); } else { $this->contents[$products_id_string] = array('qty' => $qty); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id_string]['attributes'][$option] = $value; // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')"); } } } $this->cleanup(); // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } } } function update_quantity($products_id, $quantity = '', $attributes = '') { global $customer_id; $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) { $this->contents[$products_id_string] = array('qty' => $quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { $this->contents[$products_id_string]['attributes'][$option] = $value; // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'"); } } } } function cleanup() { global $customer_id; reset($this->contents); while (list($key,) = each($this->contents)) { if ($this->contents[$key]['qty'] < 1) { unset($this->contents[$key]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); } } } } function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $total_items += $this->get_quantity($products_id); } } return $total_items; } function get_quantity($products_id) { if (isset($this->contents[$products_id])) { return $this->contents[$products_id]['qty']; } else { return 0; } } function in_cart($products_id) { if (isset($this->contents[$products_id])) { return true; } else { return false; } } function remove($products_id) { global $customer_id; unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function remove_all() { $this->reset(); } function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_list .= ', ' . $products_id; } } return substr($product_id_list, 2); } function calculate() { $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; $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']; } // BOF - AAP V1.2.1 - updated to account for no price prefix to equal actual price // attributes price if (!isset($this->contents[$products_id]['attributes'])) { $this->total += tep_add_tax($products_price, $products_tax) * $qty; } $this->weight += ($qty * $products_weight); } if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); $price_prefix = $attribute_price['price_prefix']; $option_price = $attribute_price['options_values_price']; $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $products_stuff = tep_db_fetch_array($products_query); $products_price = $products_stuff['products_price']; if ($price_prefix == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } if ($price_prefix == '-') { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } if ($price_prefix == '') { if ($attribute_price['options_values_price'] == '0') $this->total += tep_add_tax($products_price, $products_tax) * $qty; } if ($attribute_price['options_values_price'] > '0') { if ($price_prefix == '') { if (ceil($option_price) != ceil($products_price)) { $this->total += tep_add_tax($attribute_price['options_values_price'], $products_tax) * $qty; } else { $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->total += tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax) * $qty; } } } } } } } // subtotal function for attributes price function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); $price_prefix = $attribute_price['price_prefix']; $option_price = $attribute_price['options_values_price']; $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $products_stuff = tep_db_fetch_array($products_query); $products_price = $products_stuff['products_price']; //Check for special price $products_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$products_id . "'"); $products_stuff = tep_db_fetch_array($products_query); if($products_stuff['specials_new_products_price'] != ''){ $products_price = $products_stuff['specials_new_products_price']; } if ($price_prefix == '+') { $attributes_price += $option_price; } if ($price_prefix == '-') { $attributes_price -= $option_price; } if (($price_prefix == '') and ($option_price > 0)) $attributes_price += tep_adjust_price($option_price,$products_price); else $attributes_price+= $option_price; } } return $attributes_price; } // EOF - AAP V1.2.1 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; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } } ?> <?php/* $Id: general.php,v 1.231 2003/07/09 01:15:48 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License*/ ////// Stop from parsing any further PHP code function tep_exit() { tep_session_close(); exit(); } ////// Redirect to another page or site function tep_redirect($url) { if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false)); } if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL } } header('Location: ' . $url); tep_exit(); } ////// Parse the data used in the html tags to ensure the tags will not break function tep_parse_input_field_data($data, $parse) { return strtr(trim($data), $parse); } function tep_output_string($string, $translate = false, $protected = false) { if ($protected == true) { return htmlspecialchars($string); } else { if ($translate == false) { return tep_parse_input_field_data($string, array('"' => '"')); } else { return tep_parse_input_field_data($string, $translate); } } } function tep_output_string_protected($string) { return tep_output_string($string, false, true); } function tep_sanitize_string($string) { $string = ereg_replace(' +', ' ', trim($string)); return preg_replace("/[<>]/", '_', $string); } ////// Return a random row from a database query function tep_random_select($query) { $random_product = ''; $random_query = tep_db_query($query); $num_rows = tep_db_num_rows($random_query); if ($num_rows > 0) { $random_row = tep_rand(0, ($num_rows - 1)); tep_db_data_seek($random_query, $random_row); $random_product = tep_db_fetch_array($random_query); } return $random_product; } ////// Return a product's name// TABLES: products function tep_get_products_name($product_id, $language = '') { global $languages_id; if (empty($language)) $language = $languages_id; $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language . "'"); $product = tep_db_fetch_array($product_query); return $product['products_name']; } ////// Return a product's special price (returns nothing if there is no offer)// TABLES: products function tep_get_products_special_price($product_id) { $product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status"); $product = tep_db_fetch_array($product_query); return $product['specials_new_products_price']; } ////// Return a product's stock// TABLES: products function tep_get_products_stock($products_id) { $products_id = tep_get_prid($products_id); $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $stock_values = tep_db_fetch_array($stock_query); return $stock_values['products_quantity']; } ////// Check if the required stock is available// If insufficent stock is available return an out of stock message function tep_check_stock($products_id, $products_quantity) { $stock_left = tep_get_products_stock($products_id) - $products_quantity; $out_of_stock = ''; if ($stock_left < 0) { $out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>'; } return $out_of_stock; } ////// Break a word in a string if it is longer than a specified length ($len) function tep_break_string($string, $len, $break_char = '-') { $l = 0; $output = ''; for ($i=0, $n=strlen($string); $i<$n; $i++) { $char = substr($string, $i, 1); if ($char != ' ') { $l++; } else { $l = 0; } if ($l > $len) { $l = 1; $output .= $break_char; } $output .= $char; } return $output; } ////// Return all HTTP GET variables, except those passed as a parameter function tep_get_all_get_params($exclude_array = '') { global $HTTP_GET_VARS; if (!is_array($exclude_array)) $exclude_array = array(); $get_url = ''; if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) { reset($HTTP_GET_VARS); while (list($key, $value) = each($HTTP_GET_VARS)) { if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) { $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&'; } } } return $get_url; } ////// Returns an array with countries// TABLES: countries function tep_get_countries($countries_id = '', $with_iso_codes = false) { $countries_array = array(); if (tep_not_null($countries_id)) { if ($with_iso_codes == true) { $countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name'], 'countries_iso_code_2' => $countries_values['countries_iso_code_2'], 'countries_iso_code_3' => $countries_values['countries_iso_code_3']); } else { $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'"); $countries_values = tep_db_fetch_array($countries); $countries_array = array('countries_name' => $countries_values['countries_name']); } } else { $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name"); while ($countries_values = tep_db_fetch_array($countries)) { $countries_array[] = array('countries_id' => $countries_values['countries_id'], 'countries_name' => $countries_values['countries_name']); } } return $countries_array; } ////// Alias function to tep_get_countries, which also returns the countries iso codes function tep_get_countries_with_iso_codes($countries_id) { return tep_get_countries($countries_id, true); } ////// Generate a path to categories function tep_get_path($current_category_id = '') { global $cPath_array; if (tep_not_null($current_category_id)) { $cp_size = sizeof($cPath_array); if ($cp_size == 0) { $cPath_new = $current_category_id; } else { $cPath_new = ''; $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'"); $last_category = tep_db_fetch_array($last_category_query); $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); $current_category = tep_db_fetch_array($current_category_query); if ($last_category['parent_id'] == $current_category['parent_id']) { for ($i=0; $i<($cp_size-1); $i++) { $cPath_new .= '_' . $cPath_array[$i]; } } else { for ($i=0; $i<$cp_size; $i++) { $cPath_new .= '_' . $cPath_array[$i]; } } $cPath_new .= '_' . $current_category_id; if (substr($cPath_new, 0, 1) == '_') { $cPath_new = substr($cPath_new, 1); } } } else { $cPath_new = implode('_', $cPath_array); } return 'cPath=' . $cPath_new; } ////// Returns the clients browser function tep_browser_detect($component) { global $HTTP_USER_AGENT; return stristr($HTTP_USER_AGENT, $component); } ////// Alias function to tep_get_countries() function tep_get_country_name($country_id) { $country_array = tep_get_countries($country_id); return $country_array['countries_name']; } ////// Returns the zone (State/Province) name// TABLES: zones function tep_get_zone_name($country_id, $zone_id, $default_zone) { $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'"); if (tep_db_num_rows($zone_query)) { $zone = tep_db_fetch_array($zone_query); return $zone['zone_name']; } else { return $default_zone; } } ////// Returns the zone (State/Province) code// TABLES: zones function tep_get_zone_code($country_id, $zone_id, $default_zone) { $zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'"); if (tep_db_num_rows($zone_query)) { $zone = tep_db_fetch_array($zone_query); return $zone['zone_code']; } else { return $default_zone; } } ////// Wrapper function for round() function tep_round($number, $precision) { if (strpos($number, '.') && (strlen(substr($number, strpos($number, '.')+1)) > $precision)) { $number = substr($number, 0, strpos($number, '.') + 1 + $precision + 1); if (substr($number, -1) >= 5) { if ($precision > 1) { $number = substr($number, 0, -1) + ('0.' . str_repeat(0, $precision-1) . '1'); } elseif ($precision == 1) { $number = substr($number, 0, -1) + 0.1; } else { $number = substr($number, 0, -1) + 1; } } else { $number = substr($number, 0, -1); } } return $number; } ////// Returns the tax rate for a zone / class// TABLES: tax_rates, zones_to_geo_zones function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) { global $customer_zone_id, $customer_country_id; if ( ($country_id == -1) && ($zone_id == -1) ) { if (!tep_session_is_registered('customer_id')) { $country_id = STORE_COUNTRY; $zone_id = STORE_ZONE; } else { $country_id = $customer_country_id; $zone_id = $customer_zone_id; } } $tax_query = tep_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' group by tr.tax_priority"); if (tep_db_num_rows($tax_query)) { $tax_multiplier = 1.0; while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier *= 1.0 + ($tax['tax_rate'] / 100); } return ($tax_multiplier - 1.0) * 100; } else { return 0; } } ////// Return the tax description for a zone / class// TABLES: tax_rates; function tep_get_tax_description($class_id, $country_id, $zone_id) { $tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority"); if (tep_db_num_rows($tax_query)) { $tax_description = ''; while ($tax = tep_db_fetch_array($tax_query)) { $tax_description .= $tax['tax_description'] . ' + '; } $tax_description = substr($tax_description, 0, -3); return $tax_description; } else { return TEXT_UNKNOWN_TAX_RATE; } } // BOF AAP V1.2.1// actual attribute price adjustment (used with no price prefix only) function tep_adjust_price($attribute, $price) { global $currencies; $adjustment = ($attribute-$price); return $adjustment; }//EOF AAP V1.2.1// Add tax to a products price function tep_add_tax($price, $tax) { global $currencies; if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) { return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax); } else { return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); } } // Calculates Tax rounding the result function tep_calculate_tax($price, $tax) { global $currencies; return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); } ////// Return the number of products in a category// TABLES: products, products_to_categories, categories function tep_count_products_in_category($category_id, $include_inactive = false) { $products_count = 0; if ($include_inactive == true) { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'"); } else { $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'"); } $products = tep_db_fetch_array($products_query); $products_count += $products['total']; $child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'"); if (tep_db_num_rows($child_categories_query)) { while ($child_categories = tep_db_fetch_array($child_categories_query)) { $products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive); } } return $products_count; } ////// Return true if the category has subcategories// TABLES: categories function tep_has_category_subcategories($category_id) { $child_category_query = tep_db_query("select count(*) as count from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'"); $child_category = tep_db_fetch_array($child_category_query); if ($child_category['count'] > 0) { return true; } else { return false; } } ////// Returns the address_format_id for the given country// TABLES: countries; function tep_get_address_format_id($country_id) { $address_format_query = tep_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'"); if (tep_db_num_rows($address_format_query)) { $address_format = tep_db_fetch_array($address_format_query); return $address_format['format_id']; } else { return '1'; } } ////// Return a formatted address// TABLES: address_format function tep_address_format($address_format_id, $address, $html, $boln, $eoln) { $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'"); $address_format = tep_db_fetch_array($address_format_query); $company = tep_output_string_protected($address['company']); if (isset($address['firstname']) && tep_not_null($address['firstname'])) { $firstname = tep_output_string_protected($address['firstname']); $lastname = tep_output_string_protected($address['lastname']); } elseif (isset($address['name']) && tep_not_null($address['name'])) { $firstname = tep_output_string_protected($address['name']); $lastname = ''; } else { $firstname = ''; $lastname = ''; } $street = tep_output_string_protected($address['street_address']); $suburb = tep_output_string_protected($address['suburb']); $city = tep_output_string_protected($address['city']); $state = tep_output_string_protected($address['state']); if (isset($address['country_id']) && tep_not_null($address['country_id'])) { $country = tep_get_country_name($address['country_id']); if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) { $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state); } } elseif (isset($address['country']) && tep_not_null($address['country'])) { $country = tep_output_string_protected($address['country']); } else { $country = ''; } $postcode = tep_output_string_protected($address['postcode']); $zip = $postcode; if ($html) {// HTML Mode $HR = '<hr>'; $hr = '<hr>'; if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults $CR = '<br>'; $cr = '<br>'; $eoln = $cr; } else { // Use values supplied $CR = $eoln . $boln; $cr = $CR; } } else {// Text Mode $CR = $eoln; $cr = $CR; $HR = '----------------------------------------'; $hr = '----------------------------------------'; } $statecomma = ''; $streets = $street; if ($suburb != '') $streets = $street . $cr . $suburb; if ($country == '') $country = tep_output_string_protected($address['country']); if ($state != '') $statecomma = $state . ', '; $fmt = $address_format['format']; eval("\$address = \"$fmt\";"); if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) { $address = $company . $cr . $address; } return $address; } ////// Return a formatted address// TABLES: customers, address_book function tep_address_label($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "\n") { $address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'"); $address = tep_db_fetch_array($address_query); $format_id = tep_get_address_format_id($address['country_id']); return tep_address_format($format_id, $address, $html, $boln, $eoln); } function tep_row_number_format($number) { if ( ($number < 10) && (substr($number, 0, 1) != '0') ) $number = '0' . $number; return $number; } function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') { global $languages_id; if (!is_array($categories_array)) $categories_array = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']); if ($categories['categories_id'] != $parent_id) { $categories_array = tep_get_categories($categories_array, $categories['categories_id'], $indent . ' '); } } return $categories_array; } function tep_get_manufacturers($manufacturers_array = '') { if (!is_array($manufacturers_array)) $manufacturers_array = array(); $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name']); } return $manufacturers_array; } ////// Return all subcategory IDs// TABLES: categories function tep_get_subcategories(&$subcategories_array, $parent_id = 0) { $subcategories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$parent_id . "'"); while ($subcategories = tep_db_fetch_array($subcategories_query)) { $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id']; if ($subcategories['categories_id'] != $parent_id) { tep_get_subcategories($subcategories_array, $subcategories['categories_id']); } } } // Output a raw date string in the selected locale date format// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS function tep_date_long($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $year = (int)substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year)); } ////// Output a raw date string in the selected locale date format// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers function tep_date_short($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false; $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@date('Y', mktime( Quote Link to comment Share on other sites More sharing options...
Qihun Posted February 23, 2006 Share Posted February 23, 2006 do not need to change any other files , only classes/shopping_cart and function/general.php and I see files i uploaded to thread were cut so look for BOF AAP V1.2.1...... ....EOF AAP V1.2.1 and add this piece of code to your file Quote Link to comment Share on other sites More sharing options...
magicsenses Posted February 27, 2006 Share Posted February 27, 2006 Hi there! :) I've just installed the contribution Actual Attribute Price. The last one. And I have a problem. :( Example: I sell body wash for $6. This is in the description of the item. The bottles come in 4oz and 8oz. Here is how the attributes look like: Available options: Weight: 4 fl. oz 8 fl. oz ($10.00) For the 4oz bottles I set the attribute to 0 +. For the 8oz bottles I set the attribute to $10. (no prefix) Now, when I add the items to the cart, everything is perfect. The problem pops up when I try to checkout... the price of the 8oz bottles is added to the initial price of the item. What do I do wrong? :( I can't wait to hear from you! Here is My Webpage The product I've been testing on is called "50/50 Body Wash" Thank you! Simone Quote Link to comment Share on other sites More sharing options...
ATeschner Posted February 27, 2006 Share Posted February 27, 2006 The problem pops up when I try to checkout... the price of the 8oz bottles is added to the initial price of the item. What do I do wrong? :( Simone, I don't think you did anything wrong. I was just trying to figure this one out a couple of days ago. Qihun has pointed out that this worked properly in a previous version (1.2.2) and he has rolled back to that version to fix the problem. So something has happened to the code between 1.2.2 and current to cause this bug. I have put this one on the back burner until my store is a little closer to opening, but figuring it out is definately on my to-do list. :mellow: Good luck! Quote Link to comment Share on other sites More sharing options...
magicsenses Posted February 28, 2006 Share Posted February 28, 2006 Thank you, Amber! :) My store is open starting today. I am still using the +/-. I'll try and figure it out next week. If you solve the problem before I do, please, keep me posted. hugs, Simone Simone, I don't think you did anything wrong. I was just trying to figure this one out a couple of days ago. Qihun has pointed out that this worked properly in a previous version (1.2.2) and he has rolled back to that version to fix the problem. So something has happened to the code between 1.2.2 and current to cause this bug. I have put this one on the back burner until my store is a little closer to opening, but figuring it out is definately on my to-do list. :mellow: Good luck! Quote Link to comment Share on other sites More sharing options...
AlexStudio Posted March 5, 2006 Share Posted March 5, 2006 I have tried EVERY version of this contrib and NONE of them work for me, including EVERY modification post in this thread. No matter how hard I tried, the best it can get is to show the actual price in the option dropdown menu of the product info page, and the check out page as well. But when it goes to the order confirm page, the price is WRONG!!!!! I swith to the contrib http://www.oscommerce.com/community/contributions,2487 and that one works!!! So if you only want to show the actual price in option dropdown list of the product info page, the above one is much easier and stable. Quote Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored. Link to comment Share on other sites More sharing options...
edie822 Posted March 22, 2006 Share Posted March 22, 2006 I used version 1.2.2 and now my prices dont double when am checking out thanks Quote Link to comment Share on other sites More sharing options...
♥stubbsy Posted March 23, 2006 Share Posted March 23, 2006 Hi there, Is it possible to make this only show a price in the drop drown if it is different to the product price? E.g say i've got some boots which are available in all sizes and all colours for the same price, i don't need them to show the price in the drop down, only the available sizes and colours. But if one of the options was more expensive then it would show prices next to each option Any ideas? Cheers stubbsy Quote Link to comment Share on other sites More sharing options...
deeman001 Posted March 25, 2006 Share Posted March 25, 2006 Thank you, Amber! :)My store is open starting today. I am still using the +/-. I'll try and figure it out next week. If you solve the problem before I do, please, keep me posted. hugs, Simone I was able to fix the problem of the attribute item being added to the product price in the product details and totals of checkout_confirmation.php for the ActualAttributesPrices_refreshed contrib. I updated two files. /////////// FIRST FILE UPDATED /////////////// In the first file I updated the function "attributes_price()" in catalog\includes\classes\shopping_cart.php at approx line 293 (see my code at the bottom of this post): Updates to the function: My new function now accepts a second variable (product price $prod_price) which is then subtracted from the attribute price if the price_prefix == '' **code below This is what step 2 of the AAP_Install.txt instructions for the ActualAttributesPrices_refreshed contrib said to do but it didn't work for me so (DONT DO THIS): /catalog/includes/classes/shopping_cart.php-- two ------------------------------------------------------------------------- Same file: DELETE: function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } else { $attributes_price -= $attribute_price['options_values_price']; } } } return $attributes_price; } ADD: //PHPMOM.COM AAP function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } elseif ($attribute_price['price_prefix'] == '-') { $attributes_price -= $attribute_price['options_values_price']; } else $attributes_price+= $attribute_price['options_values_price']; } } return $attributes_price; } -- three ----------------------------------------------------------------------- DO THIS TO catalog\includes\classes\shopping_cart.php This is the new code I used to replace the instructions above: //PHPMOM.COM AAP function attributes_price($products_id, $prod_price) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } elseif ($attribute_price['price_prefix'] == '-') { $attributes_price -= $attribute_price['options_values_price']; } elseif ($attribute_price['price_prefix'] == '') { $attributes_price += $attribute_price['options_values_price'] - $prod_price; } } } return $attributes_price; } /////////// SECOND FILE UPDATED /////////////// I made 1 update to the array in catalog\includes\classes\order.php: My update to the array now passes a second variable (product price $prod_price) into the updated function **code below There were no instructions in the original install document for this DO THIS TO catalog\includes\classes\order.php This is the updated line of code I used for the second file catalog\includes\classes\order.php: SEARCH FOR THIS 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), REPLACE WITH THIS 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id'],$products[$i]['price']), It seems to work fine for me now. Let me know if you find any bugs. Darren Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.