mtechama Posted October 7, 2005 Share Posted October 7, 2005 how do I put percentage rate on total cost? like for an example: lets say the total cost is $99.95 and the shipping rate is 19% and the total cost and shipping is $118.94? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 how do I put percentage rate on total cost? like for an example: lets say the total cost is $99.95 and the shipping rate is 19% and the total cost and shipping is $118.94? Hello is anyone going to help me? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 Hello is anyone going to help me? Don't know if this helps and maybe there is a contribution already for something like this but you make some changes to one of the shipping modules like table rate ((catalog)/includes/modules/shipping/table.php). If you look inside that file you see the following calculation $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; break; } } Now instead of $shipping = $table_cost[$i+1]; you could change that to $shipping = ($table_cost[$i+1]/100)*$order_total; Even if you use only one shipping percentage you could use the table rate module for this. One thing to keep in mind is that your figures must be weight/percetange or price/percentag related. If it is only one percentage, like the 19% you used as a sample, you could setup the table module for weight and give a high enough weight to cover for all products you have. Say your product weight is entered as 0.1 which means 100 grams you could set the table as 20000:19 meaning all packages up to 20 kg. have a 19% shipping cost calculated over de total products price. HTH Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 Don't know if this helps and maybe there is a contribution already for something like this but you make some changes to one of the shipping modules like table rate ((catalog)/includes/modules/shipping/table.php).If you look inside that file you see the following calculation $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { $shipping = $table_cost[$i+1]; break; } } Now instead of $shipping = $table_cost[$i+1]; you could change that to $shipping = ($table_cost[$i+1]/100)*$order_total; Even if you use only one shipping percentage you could use the table rate module for this. One thing to keep in mind is that your figures must be weight/percetange or price/percentag related. If it is only one percentage, like the 19% you used as a sample, you could setup the table module for weight and give a high enough weight to cover for all products you have. Say your product weight is entered as 0.1 which means 100 grams you could set the table as 20000:19 meaning all packages up to 20 kg. have a 19% shipping cost calculated over de total products price. HTH No No No I am not talking about Weight I am talking about total of the order not Weight of the order Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 No No No I am not talking about Weight I am talking about total of the order not Weight of the order The calculation does use the total order amount with the percentage. The percentage however must be related to something and the table module has only weight and price. You surely have some weight to set on your packages or use the price ? Read again what I wrote. Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 The calculation does use the total order amount with the percentage. The percentage however must be related to something and the table module has only weight and price.You surely have some weight to set on your packages or use the price ? Read again what I wrote. Ok I think you don't understand what I am trying to say. ok lets say the total order before shipping is 99.95 ok and then 19% on the shipping. ok lets add it together. 99.95 X 19% = $18.99 $18.99 is your shipping cost 99.95 + 18.99 = $118.94 is your total cost and shipping there is no weight involved Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 Ok I think you don't understand what I am trying to say. ok lets say the total order before shipping is 99.95 ok and then 19% on the shipping. ok lets add it together. 99.95 X 19% = $18.99 $18.99 is your shipping cost 99.95 + 18.99 = $118.94 is your total cost and shipping there is no weight involved No no, I understand what you are trying to do but maybe the table rate module is a bad sample for this. If you look closely at the routine and know how the table module works you see that it is reading a string looking like something as 1:5.00,2:7.50,5:10.00 With normal use, based on weight, this says packages up to 1 kg. cost $5, packages between 1 and 2 kg. cost $7.50 and packages in between 2 and 5 kg. cost $10 In your case you want the have it percentage based on the total order amount. That's oke but the 19% has to be tied to something. So if you have your product weights set from, well, let's say 0.1 kg. to 2 kg and someone buys 2 lightweights and one 2 kg products you have 2.2 kg. If the table rate says 20000:19 it means, in your case, packages with weight up to 20 kg. have a percentage rate of 19 Inside the table module I changed the calculation so it will use that 19 as a percentage and calclate that against the total order amount. The weight is only there to pull the percentage in. But maybe the flate rate shipping module would be easier for you if my assumption is correct that you always use 19%. You'll have to make a few more changes to get that working but it is not overly complicated. In your catalog/includes/modules/shipping/flat.php change function quote($method = '') { global $order; to function quote($method = '') { global $order, $cart; and right below that add $order_total = $cart->show_total(); a little below you see 'cost' => MODULE_SHIPPING_FLAT_COST))); change that to 'cost' => (MODULE_SHIPPING_FLAT_COST/100)*$order_total))); That does the same as with the table rate sample only now you only have one percentage at your disposal but if that is fine your set Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 No no, I understand what you are trying to do but maybe the table rate module is a bad sample for this.If you look closely at the routine and know how the table module works you see that it is reading a string looking like something as 1:5.00,2:7.50,5:10.00 With normal use, based on weight, this says packages up to 1 kg. cost $5, packages between 1 and 2 kg. cost $7.50 and packages in between 2 and 5 kg. cost $10 In your case you want the have it percentage based on the total order amount. That's oke but the 19% has to be tied to something. So if you have your product weights set from, well, let's say 0.1 kg. to 2 kg and someone buys 2 lightweights and one 2 kg products you have 2.2 kg. If the table rate says 20000:19 it means, in your case, packages with weight up to 20 kg. have a percentage rate of 19 Inside the table module I changed the calculation so it will use that 19 as a percentage and calclate that against the total order amount. The weight is only there to pull the percentage in. But maybe the flate rate shipping module would be easier for you if my assumption is correct that you always use 19%. You'll have to make a few more changes to get that working but it is not overly complicated. In your catalog/includes/modules/shipping/flat.php change function quote($method = '') { global $order; to function quote($method = '') { global $order, $cart; and right below that add $order_total = $cart->show_total(); a little below you see 'cost' => MODULE_SHIPPING_FLAT_COST))); change that to 'cost' => (MODULE_SHIPPING_FLAT_COST/100)*$order_total))); That does the same as with the table rate sample only now you only have one percentage at your disposal but if that is fine your set I just cant get it to work the way I want it I just cant get it to work the way I want it this is what its doing... on the flat rate is its not giving the percentage rate of the total. when I put for 25% it keeps giving $2.50 or when I put 25000 that gives me $25,000 why? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 I forgot to Mention that I am going to use UPS only ok lets say the total order before shipping is 99.95 ok and then 19% on the shipping. ok lets add it together. 99.95 X 19% = $18.99 $18.99 is your shipping cost 99.95 + 18.99 = $118.94 is your total cost and shipping there is no weight involved Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 I just cant get it to work the way I want itthis is what its doing... on the flat rate is its not giving the percentage rate of the total. when I put for 25% it keeps giving $2.50 or when I put 25000 that gives me $25,000 why? Wade, Just did a test with the changes and settings I gave you and for your sample product of 99.95 the total cost including shipment is exactly 118.94 How did you fill in the the flat rate shipping cost ? It must be 19, not 19% or something, just the percentage value. regards, Howard I forgot to Mention that I am going to use UPS only ok lets say the total order before shipping is 99.95 ok and then 19% on the shipping. ok lets add it together. 99.95 X 19% = $18.99 $18.99 is your shipping cost 99.95 + 18.99 = $118.94 is your total cost and shipping there is no weight involved Wade, Maybe a stupid question but what's the use getting a UPS quote if you want to use order total x fixed percentage = shipping cost ? Howard Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 Wade, Just did a test with the changes and settings I gave you and for your sample product of 99.95 the total cost including shipment is exactly 118.94 How did you fill in the the flat rate shipping cost ? It must be 19, not 19% or something, just the percentage value. regards, Howard ok lets say the total order before shipping is 199.95 ok and then 19% on the shipping. ok lets add it together. 199.95 X 19% = $37.99 $37.99 is your shipping cost 199.95 + 37.99 = $237.94 is your total cost and shipping there is no weight involved instead it shows $37.99 it shows just $19.00 Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 ok lets say the total order before shipping is 199.95 ok and then 19% on the shipping. ok lets add it together. 199.95 X 19% = $37.99 $37.99 is your shipping cost 199.95 + 37.99 = $237.94 is your total cost and shipping there is no weight involved instead it shows $37.99 it shows just $19.00 Sorry to say but that's exactly what I get using the flat rate module with the changes ?! Can you give me your settings for this module and are you sure you did change 'cost' => (MODULE_SHIPPING_FLAT_COST/100)*$order_total))); correctly ? Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 On what file? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 On what file? (catalog)/includes/modules/shipping/flat.php Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 on the flat.php I am getting an error............ Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/content/g/i/f/giftshop/html/catalog/includes/modules/shipping/flat.php on line 51 Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 on the flat.php I am getting an error............ Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/content/g/i/f/giftshop/html/catalog/includes/modules/shipping/flat.php on line 51 Nevermind I got Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 Ok I got one more question what module do I use lets different State has different percentage rates? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
wheeloftime Posted October 8, 2005 Share Posted October 8, 2005 Ok I got one more question what module do I use lets different State has different percentage rates? There is no module for that sort of thing as far as I know. The zones module would be a good option because you can have different zones which can be defined as states. However the setup is similar to the table rate module which means you must create some relation between percentage and weight/price. As I tried to explain the weight is only used to pull in the correct percentage otherwise it won't work. I have the feeling though you still don't understand what I tried to explain ?! Link to comment Share on other sites More sharing options...
mtechama Posted October 8, 2005 Author Share Posted October 8, 2005 I just realize about something I want to charge $6.50 for shipping for total orders under $25.00 and over $25.00 charge 25% percentage rate on shipping how can I do that? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
mtechama Posted October 9, 2005 Author Share Posted October 9, 2005 Anyone!?!?!?! Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
mtechama Posted October 9, 2005 Author Share Posted October 9, 2005 ok I got my percentage rate going on total orders ok my question is I want to charge 6.50 for shipping up to $25.00 and after that its percentage rate from $25.01 and up? how can I do that Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted October 9, 2005 Share Posted October 9, 2005 <?php /* $Id: table.php,v 1.5 2002/11/19 01:48:08 dgw_ Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Released under the GNU General Public License */ define('MODULE_SHIPPING_TABLE2_TEXT_TITLE', 'Rush Order Table Rate'); define('MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION', 'Rush Order Table Rate'); define('MODULE_SHIPPING_TABLE2_TEXT_WAY', 'This adds a 15% surcharge to your order total and ensures made-to-order items leave our shop within 2 weeks'); define('MODULE_SHIPPING_TABLE2_TEXT_WEIGHT', 'Weight'); define('MODULE_SHIPPING_TABLE2_TEXT_AMOUNT', 'Amount'); ?> <?php /* $Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class table2 { var $code, $title, $description, $icon, $enabled; // class constructor function table2() { global $order; $this->code = 'table2'; $this->title = MODULE_SHIPPING_TABLE2_TEXT_TITLE; $this->description = MODULE_SHIPPING_TABLE2_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_TABLE2_SORT_ORDER; $this->icon = ''; $this->tax_class = MODULE_SHIPPING_TABLE2_TAX_CLASS; $this->enabled = ((MODULE_SHIPPING_TABLE2_STATUS == 'True') ? true : false); if (is_object($order)) { // disable the module if the order only contains virtual products if ($this->enabled == true) { global $cart; if ($cart->show_total() == 0.00) { $this->enabled = false; } } } if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE2_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE2_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } // class methods function quote($method = '') { global $order, $cart, $shipping_weight, $shipping_num_boxes; if (MODULE_SHIPPING_TABLE2_MODE == 'price') { $order_total = $cart->show_total(); } else { $order_total = $shipping_weight; } $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE2_COST); $size = sizeof($table_cost); for ($i=0, $n=$size; $i<$n; $i+=2) { if ($order_total <= $table_cost[$i]) { if ((MODULE_SHIPPING_TABLE_MODE == 'price') && (strpos($table_cost[$i+1],'%')) && (strpos($table_cost[$i+1],'+'))) { $shipping = before('+',$table_cost[$i+1]) + $order_total * (after('+',$table_cost[$i+1])/100); } elseif ((MODULE_SHIPPING_TABLE_MODE == 'price') && (strpos($table_cost[$i+1],'%'))) { $shipping = $order_total * ($table_cost[$i+1]/100); } else { $shipping = $table_cost[$i+1]; } break; } } if (MODULE_SHIPPING_TABLE2_MODE == 'weight') { $shipping = $shipping * $shipping_num_boxes; } $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TABLE2_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_TABLE2_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_TABLE2_HANDLING))); if ($this->tax_class > 0) { $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); return $this->quotes; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE2_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE2_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE2_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE2_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE2_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_TABLE2_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE2_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_SHIPPING_TABLE2_STATUS', 'MODULE_SHIPPING_TABLE2_COST', 'MODULE_SHIPPING_TABLE2_MODE', 'MODULE_SHIPPING_TABLE2_HANDLING', 'MODULE_SHIPPING_TABLE2_TAX_CLASS', 'MODULE_SHIPPING_TABLE2_ZONE', 'MODULE_SHIPPING_TABLE2_SORT_ORDER'); } } ?> :-) 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 ... Link to comment Share on other sites More sharing options...
mtechama Posted October 9, 2005 Author Share Posted October 9, 2005 What are you trying to do to me confuse me? ok on the shipping charge I $6.50 up to $25.00 I charge 25% if its over $25.00 for an example: lets say I buy something and the total is 21.50 that is it ok that is a $6.50 shipping fee ok then lets say I bought something that totals $29.65 and that is 25% percent of that total Do you understand what I am saying? is it under Modules/Order Total/Low Order Total? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted October 9, 2005 Share Posted October 9, 2005 What are you trying to do to me confuse me? ok on the shipping charge I $6.50 up to $25.00 I charge 25% if its over $25.00 for an example: lets say I buy something and the total is 21.50 that is it ok that is a $6.50 shipping fee ok then lets say I bought something that totals $29.65 and that is 25% percent of that total Do you understand what I am saying? is it under Modules/Order Total/Low Order Total? this was the code for you to add to your language files in shipping and your modules files in shipping ... a table2 rate that does eaxtly what you need. Sorry I hate to confuse you by handing out a solution I developed. Anyway this is what it looks like when installed and filled out in admin -> modules -> shipping for the new table2: (and yes it works with other values too, it works with values only % only and a combination) Rush Order Table Rate Enable Table Method True Shipping Table 25:8+15%,50:10+15%,75:12+15%,100:14+15%,150:18+15%,1000:22+15%,1000000:18% Table Method price Handling Fee 0 Tax Class --none-- Shipping Zone --none-- Sort Order 2 :-) 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 ... Link to comment Share on other sites More sharing options...
mtechama Posted October 9, 2005 Author Share Posted October 9, 2005 Ok where do I need to put the new coding at? Wade Morris Amarillo, Texas Before you do any changes on your site you need to do BACKUP! BACKUP! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.