Community Add-Ons
Free shipping per product 1.0
for osCommerce Online Merchant v2.2
-------------------------------------------------------------------------------
Free Shipping per Product 1.0 by Denis Witt <oscommerce@hausundhof.com>
-------------------------------------------------------------------------------
(German translation at the bottom)
This contribution allows you to define a free shipping option to each product.
Very useful if you have software products the customer has already access to
but if there is a serial number needed which is delivered by e-mail and you
don't want to solve this with the download option of osCommerce.
The required product setting is configurable within the admin section of
osCommerce.
This contrib is tested with osCommerce 2.2 MS2. I've no idea if it works with
older or newer versions of osCommerce. If you want to figure this out for
yourself please send me a mail if it's working or not.
This contribution is published under the GNU GENERAL PUBLIC LICENSE. See
LICENSE-file for details.
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE
THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
You could reach me by mail if you want to (german and english):
oscommerce@hausundhof.com
You could see this contribution (slightly modified) at:
https://www.ilt-training.de/shop
-------------------------------------------------------------------------------
Installation Instructions:
-------------------------------------------------------------------------------
Update mySQL-database (use phpMyAdmin or something similiar):
-------------------------------------------------------------------------------
ALTER TABLE `products` ADD `products_free_shipping` TINYINT( 1 ) DEFAULT '0' NOT NULL ;
-------------------------------------------------------------------------------
Copy files or merge them with WinMerge:
-------------------------------------------------------------------------------
If you have already installed some contributions to your shop who affecting the
following files the best way to install this contribution is to use WinMerge or
similiar software. WinMerge is available at: http://winmerge.sourceforge.net/
If your shop is not updated yet with any contribution who affected the
following files you could just copy the files in this contribution over the
original files (BACKUP FIRST!):
/catalog/checkout_shipping.php
/catalog/product_info.php
/catalog/admin/categories.php
/catalog/includes/modules/product_listing.php
/catalog/includes/languages/english/product_info.php
/catalog/includes/languages/english/checkout_shipping.php
/catalog/includes/languages/english/index.php
/catalog/admin/includes/languages/english/categories.php
-------------------------------------------------------------------------------
Deutsche Installationsanweisungen:
Diese Contribution erlaubt es für jeden Artikel festzulegen, ob Versandkosten
anfallen. Dies ist z.B. sehr nützlich, wenn man Artikel im Shop führt, die
der Kunde bereits besitzt (z.B. Software), die aber für die weitere Nutzung
eine Seriennummern oder ähnliches benötigen. Hierzu könnte man natürlich
die Downloadfunktion von osCommerce nutzen, wer die Seriennummern aber
lieber selbst generieren möchte und diese dann per E-Mail versenden will,
scheidet diese Möglichkeit aus. Beim E-Mail-Versand werden aber natürlich
keine Versandkosten fällig. Wenn ein Kunde versandkostenfreie Produkte
zusammen mit versandkostenpflichtigen Produkten bestellt, werden selbst-
verständlich die normalen Versandkosten berechnet.
Die benötigten Produkteinstellunge können komfortabel über den Adminbereich
von osCommerce vorgenommen werden.
Diese Contribution wurde mit einer Standardinstallation von osCommerce 2.2 MS2
getestet. Ich weiß nicht, ob sie auch mit einer älteren oder neueren Version
funktionieren wird. Wer es ausprobieren möchte, kann mir gerne eine Mail
schreiben, ob es funktioniert hat und welche Anpassungen eventuell noch
nötig waren/sind.
Diese Contribution untersteht der GNU General Public License. Weitere
Informationen sind in der Datei LICENSE, die diesem Paket beiliegt, zu finden.
Eine leicht modifizierte Version dieser Contribution wird im eShop der
ILT GmbH verwendet: https://www.ilt-training.de/shop/
-------------------------------------------------------------------------------
Änderungen an der mySQL-Datenbank (können mit phpMyAdmin vorgenommen werden):
-------------------------------------------------------------------------------
ALTER TABLE `products` ADD `products_free_shipping` TINYINT( 1 ) DEFAULT '0' NOT NULL ;
-------------------------------------------------------------------------------
Änderungen an Dateien:
-------------------------------------------------------------------------------
Sofern im bestehenden Shop bereits andere Contributions verwendet werden, ist
es am einfachsten, die Installation mit einem Tool wie z.B. WinMerge vorzu-
nehmen.
WinMerge ist kostenlos verfügbar unter: http://winmerge.sourceforge.net/
Wenn der Shop noch keine Contributions verwendet, oder diese keine der
folgenden Dateien betrifft, können einfach die Dateien dieser Contribution
über die Originaldateien kopiert werden. Vorher sollte auf jeden Fall ein
Backup erstellt werden:
/catalog/checkout_shipping.php
/catalog/product_info.php
/catalog/admin/categories.php
/catalog/includes/modules/product_listing.php
/catalog/includes/languages/german/product_info.php
/catalog/includes/languages/german/checkout_shipping.php
/catalog/includes/languages/german/index.php
/catalog/admin/includes/languages/german/categories.php
-------------------------------------------------------------------------------
Support-Thread: http://forums.oscommerce.de/viewtopic.php?p=97064#97064
With the original Free shipping per product, you could not have both free shipping and charged shipping products in your cart. Otherwise, you would still be charged shipping for all item items if using the per item shipping method.
I have edited checkout_shipping.php, includes/classes/shopping_cart.php and includes/modules/shipping/item.php to work so that, when using the per item shipping method, you can have both free and charged products in your cart... and, you will not be charged for the items that are free.
================
checkout_shipping.php
FIND:
$total_count = $cart->count_contents();
ADD BELOW:
$total_ship_count = $cart->count_ship_contents(); // Free shipping per product 1.0
========================
includes/classes/shopping_cart.php
FIND:
return $total_items;
}
ADD BELOW:
// BEGIN Free shipping per product 1.0
function count_ship_contents() { // get total number of items in cart
$total_items = 0;
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
/*** BEGIN - Free shipping per product 1.0 ***/
$check_free_shipping_query = tep_db_query("select products_free_shipping from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$check_free_shipping = tep_db_fetch_array($check_free_shipping_query);
$check_free_shipping_array[] = $check_free_shipping['products_free_shipping'];
if (in_array("1", $check_free_shipping_array) && !in_array("0", $check_free_shipping_array)) {
} else {
$total_items += $this->get_quantity($products_id);
}
/*** END Free - shipping per product 1.0 ***/
}
}
return $total_items;
}
// END Free shipping per product 1.0
=========================
includes/modules/shipping/item.php
FIND:
global $order, $total_count;
REPLACE WITH:
//global $order, $total_count;
global $order, $total_ship_count; // Free shipping per product 1.0
FIND:
'cost' => (MODULE_SHIPPING_ITEM_COST * $total_count) + MODULE_SHIPPING_ITEM_HANDLING)));
REPLACE WITH:
'cost' => (MODULE_SHIPPING_ITEM_COST * $total_ship_count) + MODULE_SHIPPING_ITEM_HANDLING))); // Free shipping per product 1.0
==================
That should be it... You can also just use the included files if no previous changes to them have been made.
