Individual Product Shipping Prices - v1.0 ----------------------------------------- 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 If you like this contribution and find it useful, please consider sending me a donation of any amount via Paypal to dmg@dm-gremlin.com Check out my osCommerce site at www.dm-gremlin.com/sales/ -D. M. New Database Fields: 1 ---------------------- products_ship_price in products Files to upload: 2 ------------------ catalog/includes/modules/shipping/indvship.php catalog/includes/languages/english/modules/shipping/indvship.php Files to modify: 2 ------------------ catalog/includes/classes/shopping_cart.php admin/categories.php ================ == To Install == ================ ** Step 1 ** Backup your database, and all files to be modified. ** Step 2 ** Using PHPmyadmin, or however you like to do it, run this SQL command on your database: ALTER TABLE products ADD products_ship_price DECIMAL(15,4) NOT NULL; ** Step 3 ** Open catalog/includes/classes/shopping_cart.php -> Find (near the beginning) class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; -> Add after // mod indvship var $shiptotal; // end indvship -> Find (in function reset) $this->contents = array(); $this->total = 0; $this->weight = 0; -> Add after // mod indvship $this->shiptotal = 0; // end indvship -> Find function calculate() { $this->total = 0; $this->weight = 0; -> Add after // mod indvship $this->shiptotal = 0; // end indvship -> Find // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'"); -> Add products_ship_price to query as illustrated below OR if you don't have any other mods installed here you can simply replace with // products price - indvship added products_ship_price $product_query = tep_db_query("select products_id, products_price, products_ship_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . tep_get_prid($products_id) . "'"); -> Find (a few lines down) $products_weight = $product['products_weight']; -> Add after // mod indvship $products_ship_price = $product['products_ship_price']; // end indvship -> Find $this->total += tep_add_tax($products_price, $products_tax) * $qty; -> Add after // mod indvship $this->shiptotal += ($products_ship_price * $qty); // end indvship -> Find function show_total() { $this->calculate(); return $this->total; } -> Add after function get_shiptotal() { $this->calculate(); return $this->shiptotal; } -> Save and close file ** Step 4 ** Open admin/categories.php This is pretty much the same field-adding procedure as in multi-vendor shipping, but I'll go ahead and write it out here as well. Look for these lines from top to bottom, as some are similar. -> Find $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']), 'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']), 'products_image' => (($HTTP_POST_VARS['products_image'] == 'none') ? '' : tep_db_prepare_input($HTTP_POST_VARS['products_image'])), 'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']), 'products_date_available' => $products_date_available, 'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']), 'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']), 'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']), 'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id'])); Inset a new line above the line with 'products_model'. Copy the line below onto the new line. // mod indvship 'products_ship_price' => tep_db_prepare_input($HTTP_POST_VARS['products_ship_price']), //indvship -> Find $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . tep_db_input($products_id) . "'"); -> Change it to Add products_ship_price to the beginning of the select query like this $product_query = tep_db_query("select /*mod indvship*/ products_ship_price, products_quantity, (ect... rest of query here) -> Find tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . $product['products_quantity'] . "', '" . $product['products_model'] . "', '" . $product['products_image'] . "', '" . $product['products_price'] . "', now(), '" . $product['products_date_available'] . "', '" . $product['products_weight'] . "', '0', '" . $product['products_tax_class_id'] . "', '" . $product['manufacturers_id'] . "')"); -> Change it to add products ship method (there are two changes). You do not want to just replace the line as it will interfere with any other mods you might have installed. tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, /*changes indvship*/ products_ship_price, products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . $product['products_quantity'] . "', '" . $product['products_model'] . "', /*changes indvship*/ '" . $product['products_ship_price'] . "', '" . $product['products_image'] . "', '" . $product['products_price'] . "', now(), '" . $product['products_date_available'] . "', '" . $product['products_weight'] . "', '0', '" . $product['products_tax_class_id'] . "', '" . $product['manufacturers_id'] . "')"); -> Find $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'"); -> Add p.products_ship_price to the query like this $product_query = tep_db_query("select /*changes indvship*/ p.products_ship_price, pd.products_name, (ect... rest of query here) -> Find products_price); ?> -> Add this right below the tag products_ship_price); ?> -> Find $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . $HTTP_GET_VARS['pID'] . "'"); -> Add p.products_ship_price to the query like this $product_query = tep_db_query("select /*changes indvship*/ p.products_ship_price, p.products_id, (ect.... rest of query goes here) -> Find $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%' order by pd.products_name"); } else { $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . $current_category_id . "' order by pd.products_name"); } -> Add p.products_ship_price to BOTH queries using the same method as above -> Save and close file ** Step 5 ** Upload included and modified files to their respective directories. ** Step 6 ** Add shipping price data to your products via your Admin panel. ** Step 7 ** Go to your Admin control panel, activate and configure this module in your shipping modules section. ** Step 8 ** Modify the text in catalog/includes/languages/english/modules/shipping/indvship.php to your liking. =========================== == Configure with == == Multi-Vendor Shipping == =========================== ** Step 1 ** Backup your catalog/includes/modules/shipping/mltship.php file ** Step 2 ** Open catalog/includes/modules/shipping/mltship.php -> Find //Any other module specific processing / charges should be done here break; -> Add after case "indvship": $rate = new indvship; $mltQuote = $rate->quote('indvship'); break; -> Save and close file ** Step 3 ** Upload the modified file.