Guest stijnj Posted May 26, 2004 Share Posted May 26, 2004 I needed to create this mod for someone Shippingcost gets calculated by the total order in his example : orders up to 25 shippingcost = 4.99 orders up to 50 shippingcost = 5.99 orders up to 75 shippingcost = 6.99 orders up to 100 shippingcost = 7.99 and so on -calculation is correct -all values can be editted as disired -you can set a fixed value aswell if someone is interested let me know Link to comment Share on other sites More sharing options...
Guest Albert Posted May 27, 2004 Share Posted May 27, 2004 This will be no solution for a lot of people. Unless you are selling CD's or something like that. You will have to consider the weight of every item in order to get a freight charge in most cases. This means entering weight of all goods as well. Than have to compare it against a shipping mode: Postal, Truck (or Bode as they call it in Holland/Belgium), Express Than you have a realistic charge. Some also wanne add a surcharge for orders below a certain amount. This has to be more or less flexible. I have been fiddling on it, but not enough time at the moment to complete it. The next shop i install, i will try to add all. Albert Link to comment Share on other sites More sharing options...
Guest dcwd Posted June 4, 2004 Share Posted June 4, 2004 I *so* need this MOD! I was going to post a request. I'm definitely interested!! :) Link to comment Share on other sites More sharing options...
Guest KellerKind Posted June 13, 2004 Share Posted June 13, 2004 i need this mod :rolly: Link to comment Share on other sites More sharing options...
Guest Posted June 14, 2004 Share Posted June 14, 2004 I'll take this mod. Link to comment Share on other sites More sharing options...
Guest Posted June 14, 2004 Share Posted June 14, 2004 I would like this mod as well :rolly: Link to comment Share on other sites More sharing options...
Guest stijnj Posted June 25, 2004 Share Posted June 25, 2004 MANUAL INSTALL GUIDE 1 copy / paste to cubecartdirectory/admin/lang/English.inc.php //************************ // SHIP BY TOTAL ORDER SUM //************************ $la_ship_by_order_header="Shipping by total order sum"; $la_ship_by_order_edit="edit shipping by total order"; $la_ship_by_order_error="Please complete all required fields"; $la_ship_by_order_val="Values are updated"; $la_ship_by_order_result="Result is here"; $la_ship_by_order_if="If the total order sum is over"; $la_ship_by_order_base="Base settings"; $la_ship_by_order_cost="Shippingcost is"; $la_ship_by_order_for="for orders up to"; $la_ship_by_order_add="Add"; $la_ship_by_order_next="for every next"; 2 open cubecartdirectory/admin/nav.php find about line 191 ['<?echo$la_shipping_title;?>', '<?echo"$site_url/admin/shipping.php";?>'], add below ['<?echo$la_ship_by_order_edit;?>', '<?echo"$site_url/admin/shipping_by_order.php";?>'], 3 open cubecartdirectory/order.php find about line 431 // first get shipping prices from category     $sel_cat = "select cat_id from ".$prefix."store_inventory where product = '$product'";     $result_sel_cat = mysql_query($sel_cat);     $row_cat = mysql_fetch_array($result_sel_cat);     $cat_id = $row_cat[cat_id];         $sel_ship = "select * from ".$prefix."store_category where cat_id = '$cat_id'";     $result_sel_ship = mysql_query($sel_ship);     $row_ship = mysql_fetch_array($result_sel_ship);     $per_ship = $row_ship[$per_shipment];     $per_it = $row_ship[$per_item];         select highest per_ship or per_int_ship and multiply item_ship or item_int_ship     $total_per_item = ($per_it * $quantity) + $total_per_item;     if($per_ship>$max_per_ship){$max_per_ship=$per_ship;} uncomment these lines like this (or delete them) // first get shipping prices from category     //$sel_cat = "select cat_id from ".$prefix."store_inventory where product = '$product'";     //$result_sel_cat = mysql_query($sel_cat);     //$row_cat = mysql_fetch_array($result_sel_cat);     //$cat_id = $row_cat[cat_id];         // $sel_ship = "select * from ".$prefix."store_category where cat_id = '$cat_id'";     //$result_sel_ship = mysql_query($sel_ship);     //$row_ship = mysql_fetch_array($result_sel_ship);     // $per_ship = $row_ship[$per_shipment];     // $per_it = $row_ship[$per_item];         // select highest per_ship or per_int_ship and multiply item_ship or item_int_ship     // $total_per_item = ($per_it * $quantity) + $total_per_item;     //if($per_ship>$max_per_ship){$max_per_ship=$per_ship;} find about line 446 }// ends loop for each product add below ////////////////////////////////////////////////////////////////////// ///////////    start shipping modification      ///////////// ////////////////////////////////////////////////////////////////////// //shipping gets calculated by total order sum so let's get the sum first $cart_total=$cart->cart_total($prefix,$session,$sale); //now select data set by the admin $query = "SELECT * FROM ".$prefix."store_ship_by_ordersum"; $result = mysql_query($query); while($row = mysql_fetch_array($result))     {     $ship_amount = $row["ship_amount"];     $ship_amount_base = $row["ship_amount_base"];     $ship_amount_up = $row["ship_amount_up"];     $ship_amount_up_base = $row["ship_amount_up_base"];     } if($cart_total>$ship_amount_base) $rest_ship = $cart_total - $ship_amount_base; $ship_calc = ($rest_ship/$ship_amount_up_base)*$ship_amount_up; $ship_calc = ceil($ship_calc); $total_ship = $ship_calc + $ship_amount; if($cart_total<$ship_amount_base) $total_ship = $ship_amount; if($cart_total==$ship_amount_base) $total_ship = $ship_amount; //////////////////////////////////////////////////////////////////////// ///////////////  end shipping modification        ////////////// //////////////////////////////////////////////////////////////////////// find about line 484 $total_ship = $total_per_item + $max_per_ship; uncomment like //$total_ship = $total_per_item + $max_per_ship; 4 Run SQL queries on your cubecart database : CREATE TABLE store_ship_by_ordersum (  ship_amount decimal(30,2) NOT NULL default '0.00',  ship_amount_base decimal(30,2) NOT NULL default '0.00',  ship_amount_up decimal(30,2) NOT NULL default '0.00',  ship_amount_up_base decimal(30,2) NOT NULL default '0.00' ) TYPE=MyISAM; # # Gegevens worden uitgevoerd voor tabel `store_ship_by_ordersum` # INSERT INTO store_ship_by_ordersum VALUES ('4.99', '25.00', '1.00', '25.00'); 6 save next file as shipping_by_order.php and upload to admindir <?php /*************************************************************************** * *              MOD INFO * ************************************************************************** * *    File info : shipping by order.php *           add-on for cubecart version 2 * *    Author   :Stijn Jammaers *           * *    Last update: 24/05/2004 * * * * * * **************************************************************************/ session_start(); if (!session_is_registered("admin"))  {   header("Location: login.php");  } if(session_is_registered("admin")){ include ("config.php"); include( "settings.inc.php"); $url="index"; include_once ("header.inc.php"); echo"<H2>$la_ship_by_order_header</H2></font><font size='1'> (CubeCart mod by <b>Stijn Jammaers ©<a target='_blank' href='http://www.pastij.be'> www.pastij.be</a>"; if($submit) { $goback="<p align=\"center\"><a href=\"java script:history.back()\">$la_try_again</a></p>"; if(empty($ship_amount)or(empty($ship_amount_base))or(empty($ship_amount_up))or(empty($ship_amount_up_base)))         { echo "<p align=\"center\">$la_ship_by_order_error</p><p>$goback</p>";         exit;         } $sql_update = mysql_query("update ".$prefix."store_ship_by_ordersum set ship_amount='$ship_amount', ship_amount_base='$ship_amount_base' , ship_amount_up='$ship_amount_up' , ship_amount_up_base='$ship_amount_up_base' "); echo"<p align=\"center\">$la_ship_by_order_val</b><br><br><a href =\"shipping_by_order.php\">$la_ship_by_order_result</a></p>"; } if(!$submit){ $sql_count = "select * from ".$prefix."store_ship_by_ordersum"; $result = mysql_query ($sql_count); while($row = mysql_fetch_array($result))     {     $ship_amount = $row["ship_amount"];     $ship_amount_base = $row["ship_amount_base"];     $ship_amount_up = $row["ship_amount_up"];     $ship_amount_up_base = $row["ship_amount_up_base"];     } echo"<form action=\"shipping_by_order.php\" method=\"post\"> <table align=\"left\" width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td bgcolor=\"$colour_2\"> <table cellpadding=\"2\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\"> <tr bgcolor=\"$colour_2\"> <td valign=\"top\"width=\"25%\"><b>$la_ship_by_order_base</b></td> <td width=\"25%\"> </td> <td width=\"25%\"> </td> <td width=\"25%\"> </td></tr> <tr bgcolor=\"$colour_3\">   <td width=\"25%\" valign=\"top\" align=\"center\">$la_ship_by_order_cost</td>   <td width=\"25%\" valign=\"top\" align=\"center\">$currency<input class=\"textbox\" type=\"textbox\" size=\"6\" name=\"ship_amount\" value=\"$ship_amount\"><font color=\"990000\"><b>*</b></font></td>   <td width=\"25%\" valign=\"top\" align=\"center\">for orders up to</td>   <td width=\"25%\" valign=\"top\" align=\"center\">$currency<input class=\"textbox\" type=\"textbox\" size=\"6\" name=\"ship_amount_base\" value=\"$ship_amount_base\"><font color=\"990000\"><b>*</b></font></td>  </tr> <tr bgcolor=\"$colour_2\"> <td valign=\"top\"width=\"25%\"><b>$la_ship_by_order_if $ship_amount_base </b></td> <td width=\"25%\"> </td> <td width=\"25%\"> </td> <td width=\"25%\"> </td></tr>  <tr bgcolor=\"$colour_3\">   <td width=\"25%\" valign=\"top\" align=\"center\">$la_ship_by_order_add</td>   <td width=\"25%\" valign=\"top\" align=\"center\">$currency<input class=\"textbox\" type=\"textbox\" size=\"6\" name=\"ship_amount_up\" value=\"$ship_amount_up\"><font color=\"990000\"><b>*</b></font></td>   <td width=\"25%\" valign=\"top\" align=\"center\">$la_ship_by_order_next</td>   <td width=\"25%\" valign=\"top\" align=\"center\">$currency<input class=\"textbox\" type=\"textbox\" size=\"6\" name=\"ship_amount_up_base\" value=\"$ship_amount_up_base\"><font color=\"990000\"><b>*</b></font></td>  </tr>  </td> </table> <center><INPUT class=\"submit\" name=\"submit\" TYPE=\"submit\" VALUE=\"$la_ship_save_changes\">"; echo"</td></tr></table><br></form>"; } include_once ("footer.inc.php"); }// end if session is registered ?> 7 go to your admin ,select Settings/Shipping by total order sum to edit the values back-up your old files first if you find any bugs, repport them here, if there are no bugs... a small thank-you would be apriciated ! Stijn Link to comment Share on other sites More sharing options...
Guest Posted August 7, 2004 Share Posted August 7, 2004 :errm: Hello, I keep getting these errors and I cant figure them out please help. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/maverick/public_html/order.php on line 408 line 408: while($row = mysql_fetch_array($result)) Warning: Division by zero in /home/maverick/public_html/order.php on line 417 line 417: $ship_calc = ($rest_ship/$ship_amount_up_base)*$ship_amount_up; Those error show when you try to check out. and then...... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/maverick/public_html/admin/shipping_by_order.php on line 47 This is line 47: while($row = mysql_fetch_array($result)) Please help!!!! Link to comment Share on other sites More sharing options...
Guest stijnj Posted August 10, 2004 Share Posted August 10, 2004 I just did a fresh install, there are no errors at all CREATE TABLE store_ship_by_ordersum (  ship_amount decimal(30,2) NOT NULL default '0.00',  ship_amount_base decimal(30,2) NOT NULL default '0.00',  ship_amount_up decimal(30,2) NOT NULL default '0.00',  ship_amount_up_base decimal(30,2) NOT NULL default '0.00' ) TYPE=MyISAM; # # Gegevens worden uitgevoerd voor tabel `store_ship_by_ordersum` # INSERT INTO store_ship_by_ordersum VALUES ('4.99', '25.00', '1.00', '25.00'); do you have a prefix for your store? if so CREATE TABLE YOURPREFIXHEREstore_ship_by_ordersum (  ship_amount decimal(30,2) NOT NULL default '0.00',  ship_amount_base decimal(30,2) NOT NULL default '0.00',  ship_amount_up decimal(30,2) NOT NULL default '0.00',  ship_amount_up_base decimal(30,2) NOT NULL default '0.00' ) TYPE=MyISAM; # # Gegevens worden uitgevoerd voor tabel `store_ship_by_ordersum` # INSERT INTO YOURPREFIXHEREstore_ship_by_ordersum VALUES ('4.99', '25.00', '1.00', '25.00'); Link to comment Share on other sites More sharing options...
Guest Posted August 11, 2004 Share Posted August 11, 2004 CREATE TABLE store_ship_by_ordersum you say to create a table in the SQL database how is this accomplished, i have been haveing trouble figureing out how to add the line intothe database any help on this would be greatly apprciated??? book-worms Link to comment Share on other sites More sharing options...
Guest stijnj Posted August 11, 2004 Share Posted August 11, 2004 I'll add a small tuttorial later today about adding tables or rows to Mysql databases later today. Stijn Link to comment Share on other sites More sharing options...
Guest Posted August 11, 2004 Share Posted August 11, 2004 CREATE TABLE YOURPREFIXHEREstore_ship_by_ordersum ( Â ship_amount decimal(30,2) NOT NULL default '0.00', Â ship_amount_base decimal(30,2) NOT NULL default '0.00', Â ship_amount_up decimal(30,2) NOT NULL default '0.00', Â ship_amount_up_base decimal(30,2) NOT NULL default '0.00' ) TYPE=MyISAM; # # Gegevens worden uitgevoerd voor tabel `store_ship_by_ordersum` # INSERT INTO YOURPREFIXHEREÂ store_ship_by_ordersum VALUES ('4.99', '25.00', '1.00', '25.00'); I cant beleive thats all I was missing thanks a million as soon as I put some cash into my paypal account it's yours. you are a wizard Thank you again Link to comment Share on other sites More sharing options...
Spechal Posted August 13, 2004 Share Posted August 13, 2004 This will make it easy for you book-worms Create this file and call it whatever.php <?php include('admin/config.php'); include('admin/settings.inc.php'); mysql_query("CREATE TABLE ".$prefix."store_ship_by_ordersum ( Â ship_amount decimal(30,2) NOT NULL default '0.00', Â ship_amount_base decimal(30,2) NOT NULL default '0.00', Â ship_amount_up decimal(30,2) NOT NULL default '0.00', Â ship_amount_up_base decimal(30,2) NOT NULL default '0.00' ) TYPE=MyISAM") or die(mysql_error()); // // Gegevens worden uitgevoerd voor tabel `store_ship_by_ordersum` // mysql_query("INSERT INTO store_ship_by_ordersum VALUES ('4.99', '25.00', '1.00', '25.00')") or die(mysql_error()); ?> Upload that and execute it by visiting the page in your browser. If you see no errors, congrats. Link to comment Share on other sites More sharing options...
Guest Posted August 27, 2004 Share Posted August 27, 2004 I need a mod that caluclates shipping by a percentage, 21% to be exact, regardless of product weight or size... Can anyone help me out? [email protected] Thanks Scott Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2004 Share Posted August 28, 2004 Hi, For some reason I'm getting this error Warning: Division by zero in /home/rbusby/public_html/onlinestore/order.php on line 458 This error appears on the order summary page, and it's not showing the base shipping cost. I followed the steps outlined here in this thread. O and thanks for the script... Link to comment Share on other sites More sharing options...
Guest Posted August 28, 2004 Share Posted August 28, 2004 I need a mod that caluclates shipping by a percentage, 21% to be exact, regardless of product weight or size... Can anyone help me out? [email protected] Thanks Scott Ditto, but mines 17%. Email is in my profile. thx. Might try taking this one on myself if no response... Email me if u really need this too and I'll start some development on it. Link to comment Share on other sites More sharing options...
Spechal Posted August 28, 2004 Share Posted August 28, 2004 Percentage per product or per shopping cart? Link to comment Share on other sites More sharing options...
Guest Posted August 31, 2004 Share Posted August 31, 2004 Percentage based on merchandise total. Link to comment Share on other sites More sharing options...
Spechal Posted August 31, 2004 Share Posted August 31, 2004 Find in order.php about line 451 $total_ship = $total_per_item + $max_per_ship; Replace with $total_ship = ($cart_total * .21); //sets order shipping to 21% of cart total Link to comment Share on other sites More sharing options...
marcelva Posted September 1, 2004 Share Posted September 1, 2004 Hi, I am in The Netherlands and would like the weights to be in Kgs instead of Lbs. Where do I have to change it so the calculation will work fine? Hope someone has the answer for me ;-) Greetings, Marcel Link to comment Share on other sites More sharing options...
Spechal Posted September 1, 2004 Share Posted September 1, 2004 This calculation isn't really for either. It is just to make shipping 21% of the total order, instead of calculating shipping based on wieght. Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2004 Share Posted September 4, 2004 Hi, For some reason I'm getting this error Warning: Division by zero in /home/rbusby/public_html/onlinestore/order.php on line 458 This error appears on the order summary page, and it's not showing the base shipping cost. I followed the steps outlined here in this thread. O and thanks for the script... Does anyone have any ideas about this? Over all the script runs perfectly except the shipping calculations. Link to comment Share on other sites More sharing options...
Spechal Posted September 4, 2004 Share Posted September 4, 2004 Post up your order.php code and put a not next to the line it says there is an error on. Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2004 Share Posted September 4, 2004 Post up your order.php code and put a not next to the line it says there is an error on. Ok, I put the // next to line 458 and now the error is gone, but It's still not showing the shipping cost. I did add the shipping variables in the admin section. :D Link to comment Share on other sites More sharing options...
Spechal Posted September 4, 2004 Share Posted September 4, 2004 Um...that was my fault on your commenting out code on that page. I had a typo in there. I wanted you to post your code up in here and put a note next to line 158 to let us know which line it was. Put up (in the forum) lines 20 before the error line, and 20 after. Link to comment Share on other sites More sharing options...
Recommended Posts