Community Add-Ons

Add file to this package
Top » Shipping Modules

Individual Product Shipping Prices - v1.0
for osCommerce Online Merchant v2.2

This shipping module will allow you to set an individual shipping price for each product. This module is kind of like the 'Shipping rate per product', or 'prodrate' shipping module designed by Joe Janos, except this module does not use the 'weight' field. Instead, this module adds a new field to your products table to hold the individual shipping price data. This means that you can use this module with any other module if you like. Intigration with the contribution 'multi-vendor shipping' is also explained.

Support forum thread at: http://forums.oscommerce.com/viewtopic.php?t=50221

Legend:  Download   Report
Expand All / Collapse All
shipping class bug fix hobbynet 23 Feb 2007  

if no products exists in the shopping-box and if then the user like to pop-up the shipping-cost information - an sql-error are displayed.

I corrected the code so that the individual shipping methods (defined within the product) only displayed if the box is not empty.

=============================
backup backup backup backup backup
=============================

catalog/includes/classes/shipping.php
---------------------------------------
Find (around row 20-58):
// INDIV_SM BEGIN (this is messy i know)
global $cart;
// New to fix attributes bug
$cart_products = $cart->get_products();
$real_ids = array();
foreach($cart_products as $prod){
$real_ids[] = tep_get_prid($prod['id']);
}
$sql = "SELECT shipping_methods FROM ".TABLE_PRODUCTS." WHERE products_id IN (".implode(',',$real_ids).") AND shipping_methods IS NOT NULL AND shipping_methods <> ''";
$query = mysql_query($sql);
// End new bug fix
$allow_mod_array = array();
while($rec = mysql_fetch_array($query)){
if(empty($allow_mod_array)) $startedempty = true;
$methods_array = array();
$methods_array = explode(';',$rec['shipping_methods']);
if(!empty($methods_array)){
foreach($methods_array as $method){
$allow_mod_array[] = $method;
}
}
if($startedempty){
$startedempty = false;
}else{
$temp_array = array();
foreach($allow_mod_array as $val){
$temp_array[$val]++;
}
$allow_mod_array = array();
foreach($temp_array as $key => $val){
if($val > 1){
$allow_mod_array[] = $key;
}
}
}
}
// INDIV_SM END

and replaced it with:

// INDIV_SM BEGIN (this is messy i know)
global $cart;
// New to fix attributes bug
$cart_products = $cart->get_products();
if (tep_not_null($cart_products)) {
$real_ids = array();
foreach($cart_products as $prod){
$real_ids[] = tep_get_prid($prod['id']);
}
$sql = "SELECT shipping_methods FROM ".TABLE_PRODUCTS." WHERE products_id IN (".implode(',',$real_ids).") AND shipping_methods IS NOT NULL AND shipping_methods <> ''";
$query = mysql_query($sql);
// End new bug fix
$allow_mod_array = array();
while($rec = mysql_fetch_array($query)){
if(empty($allow_mod_array)) $startedempty = true;
$methods_array = array();
$methods_array = explode(';',$rec['shipping_methods']);
if(!empty($methods_array)){
foreach($methods_array as $method){
$allow_mod_array[] = $method;
}
}
if($startedempty){
$startedempty = false;
}else{
$temp_array = array();
foreach($allow_mod_array as $val){
$temp_array[$val]++;
}
$allow_mod_array = array();
foreach($temp_array as $key => $val){
if($val > 1){
$allow_mod_array[] = $key;
}
}
}
}
}
// INDIV_SM END


second change (around row 63-73):

Find:
// INDIV_SM START
$temp_array = $this->modules;
$this->modules = array();
foreach($temp_array as $val){
if(mysql_num_rows($query)==0 || in_array(str_replace('.php','',$val),$allow_mod_array)) {
$this->modules[] = $val;
}
}
// INDIV_SM END

and replace it with:

// INDIV_SM START
if (tep_not_null($cart_products)) {
$temp_array = $this->modules;
$this->modules = array();
foreach($temp_array as $val){
if(mysql_num_rows($query)==0 || in_array(str_replace('.php','',$val),$allow_mod_array)) {
$this->modules[] = $val;
}
}
}
// INDIV_SM END


Thats all. Hope this solve it for everyone, within my shop it works. ;-))

I've attached my shipping.php -- use winmerge or other tools to compare it with your own version! I've installed some other contribution that changed this file.

kind regards

peter

Home Country bug fix timidphper 13 Feb 2007  
Full file set and instructions timidphper 13 Feb 2007  
Full file set and instructions timidphper 13 Feb 2007  
A bug fix PenguinMan98 13 Jul 2006  
V2.0 MS2.2 for fresh OSC FWR Media 16 Nov 2005  
4.3a crashwave 4 Oct 2005  
4.3 crashwave 3 Oct 2005  
Individual Ship v4.2a homewetbar 21 Jul 2005  
Individual Ship v4.2 homewetbar 20 Jul 2005  
Updaed Instructions CrashWave 17 Mar 2005  
Individual Product Shipping V4.1 CrashWave 5 Mar 2005  
Individual Product Shipping V4.1 CrashWave 28 Feb 2005  
More files 4.1 b CrashWave 16 Feb 2005  
Forum page CrashWave 16 Feb 2005  
Individual Product Shipping V4.1 beta CrashWave 16 Feb 2005  
Individual Shipping Prices v3.2 - Show price in product info page Eyal Shoabi 22 Dec 2004  
Individual Shipping Prices v3.1 Farrukh Saeed 3 Sep 2003  
Individual Product Shipping Prices v3.0 Farrukh Saeed 3 Sep 2003  
Individual Product Shipping Prices v2.0 MS 2.2 Farrukh Saeed 24 Aug 2003  
Individual Product Shipping Prices - v1.0 D. M. Gremlin 8 Jul 2003