Free Shipping Per Product CRE Loaded/OSCommerce
So, one day I found a need to have free shipping “per product” for CRE Loaded/OSCommerce. First I search for it and found a couple candidates that seemed like they would do the job. They just seemed too complicated to even try to set up, so I decided to just figure this out on my own. Here is the solution:
You will have to update your database. You will need to add a field called 'products_free_shipping' to the 'products' table. Make it a BOOL data type with a default value of 0. There are various places you can put this code depending on what mods, if any, have been done to your current installation of either of the two carts. For CRE and if you are using the one page checkout module, you would use orders_checkout.php on or around line 127. I believe with other versions you would need to use the checkout_shipping.php file but I do not have a clue where you would need to add this code. This would also include OSComemrce, I would think. //----------------------------------------------------------------------------------- // Check for products that have free shipping on a per product basis $product_ids = array_keys($cart->contents); $prod_id_str = implode(', ', $product_ids); $strsql = "SELECT products_free_shipping FROM products "; $strsql .= "WHERE products_id IN(" . $prod_id_str . ");"; $rows = tep_db_fetch_array(tep_db_query($strsql)); foreach($rows as $index=>$row) { if($row['products_free_shipping'] == 1) { $free_shipping = true; break; } } // Modify shipping based on free shipping var (assumes free shipping module is installed) if($free_shipping == true) { $_SESSION['shipping'] = array('id' => 'free_free', 'title' => FREE_SHIPPING_TITLE, 'cost' => 0); } // End free shipping per product //-----------------------------------------------------------------------------------
As always, use this code at your own risk. If you break your own stuff don’t go blaming someone else. Always backup first… database and files!

March 12th, 2010 at 8:31 pm
I am glad that I discovered this post. I am the type of person that makes decisions based on others. Whether it be with regards to home life or business. Your blog has some interesting information and your posts inspire me to be productive. Thanks.
March 12th, 2010 at 10:28 pm
Terran,
Thanks for the kind words. I don’t post often, but when I do I try to make it worth while. Your comment has inspired my to write more.
Thank you!