Get 1 Free
for osCommerce Online Merchant v2.2
This contribution allows you to promote a product by giving a free product when
the customer buys a specified number of the product you are promoting. This is
commonly used for a "buy two, get one free" promotion, but it is more versatile
than that:
* The qualifying quantity of the product you are promoting can be any number,
including one.
* The free product can be the same as the promoted product or any other product
in your catalog.
* You can limit the free product to one per order or any number that you wish.
* Like specials, you can set a date for the offer to expire.
* You can have any number of products in this promotion with different
requirements for each.
The free product is automatically added to the customers shopping cart when they
purchase a qualifying product in the qualifying quantity (or more.) The free
product is removed when the customer removes the qualifying product from their
cart or reduces the quantity below the qualifying quantity. The customer cannot
increase the number of free products without qualifying for them. It's designed
to be fairly foolproof.
The support thread is here:
http://forums.oscommerce.com/index.php?showtopic=255288
Legend: 
Download

Report
Damit der Käufer die vorausgesetzte Kaufanzahl angezeigt bekommt, die erfüllt sein muss, damit "get1free" greift, ist folgende Änderung empfohlen:
Just find the "start Get 1 Free" section on the products_info.php and
replace:
echo '<p>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], $free_product['products_name']) . '</p>';
with:
echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_product['products_free_id']) . '" target="_self">Sie erhalten beim Kauf von ' . $free_product['products_qualify_quantity'] .' Stk. dieses Produkts gratis ' . $free_product['products_free_quantity'] .' ' . $free_product['products_name'] . ' dazu. </a>';
Addon: Linking free product oh the main product dmordred 6 Jul 2008
I'm no good with php, I just mess around a lot,so I was able to come up with a way to add a link to the free product so people can find it easier.
Someone with a better understanding can probably come out with a better solution, but here are my 2 cents! Attached is my product_info.php with g1f and attribute copier.
Just find the "start Get 1 Free" section on the products_info.php and do 2 tiny modifications:
Add :
g1f.products_free_id,
under:
$get_1_free_query = tep_db_query("select pd.products_name,
g1f.products_free_quantity,
and replace:
echo '<p>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], $free_product['products_name']) . '</p>';
with:
echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_product['products_free_id']) . '" target="_blank">FREE WITH THIS PRODUCT ' . $free_product['products_free_quantity'] .' ' . $free_product['products_name'] . '</a>';
I'm no good with php, I just mess around a lot,so I was able to come up with a way to add a link to the free product so people can find it easier.
Someone with a better understanding can probably come out with a better solution, but here are my 2 cents! Attached is my product_info.php with g1f and attribute copier.
Just replace on product_info.php:
echo '<p>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], $free_product['products_name']) . '</p>';
with
echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_product['products_free_id']) . '" target="_blank">FREE WITH THIS PRODUCT ' . $free_product['products_free_quantity'] .' ' . $free_product['products_name'] . '</a>';
Just a merging of 2 confusing steps in the install document.
COMPLETE PACKAGE
Corrected Package for version 1.4.
There was a typo in the includes/functions/get_1_free.php file
Change
// Auto expire products on get_1_free
function tep_expire_get_1_free() {
$get_1_free_query = tep_db_query("select get_1_free_id from " . TABLE_GET_1_FREE . " where status = '1' and now() >= get_1_free_expires_date and get_1_free_expires_date > 0");
if (tep_db_num_rows($specials)) {
while ($get_1_free = tep_db_fetch_array($get_1_free_query)) {
tep_set_get_1_free_status($get_1_free['get_1_free_id'], '0');
}
}
}
to
// Auto expire products on get_1_free
function tep_expire_get_1_free() {
$get_1_free_query = tep_db_query("select get_1_free_id from " . TABLE_GET_1_FREE . " where status = '1' and now() >= get_1_free_expires_date and get_1_free_expires_date > 0");
if (tep_db_num_rows($get_1_free_query)) {
while ($get_1_free = tep_db_fetch_array($get_1_free_query)) {
tep_set_get_1_free_status($get_1_free['get_1_free_id'], '0');
}
}
}
This version adds the function to remove the offer once the expire date has passed..
+++++++++++++++++++++
Upgrade v 1.3 to 1.4:
+++++++++++++++++++++
========================
Changes in this version:
========================
Bug fixes/Features:
* Auto expire now works.
===============
Modified Files:
===============
The following files have been modified from v 1.2:
catalog/includes/application_top.php
=============
Installation:
=============
Modify or replace the above files. See the following sections.
=============
Modify Files:
=============
First, open catalog/includes/application_top.php and find the following code
---------------------------------------------------------------------------------------
// auto expire special products
require(DIR_WS_FUNCTIONS . 'specials.php');
tep_expire_specials();
---------------------------------------------------------------------------------------
add after
---------------------------------------------------------------------------------------
// auto expire get_1_free products
require(DIR_WS_FUNCTIONS . 'get_1_free.php');
tep_expire_get_1_free();
---------------------------------------------------------------------------------------
Upload
catalog/includes/function/get_1_free.php
++++++++++++++++++++++++++++
End of Upgrade v 1.3 to 1.4
++++++++++++++++++++++++++++
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Fixed Problem that data is not taken over when editing.
Added possibility to set standard values for adding new data.
Change function in admin/includes/general.php and overwrite get_1_free.php V. 1.3 with the one in the package.
This is a rollup of all of the patches below plus everything posted on the forum. This is a complete package. Thanks to everyone who contributed code or suggestions to this package.
Regards
Jim
There was a $ missing in the install.txt file of the download "Get 1 Free 1.2a bugfix". Fix it manually in row 187:
'products_name' => free_product['name'],
--- becomes ---
'products_name' => $free_product['name'],
You can alternatively use the fixed install.txt that I upload herewith.
Greets
FloM
Jusr small bug fix that I found in classes/shopping_cart.php.
If expiration of free product offer not set - feature won't work.
Changed only 1 file: catalog/includes/classes/shopping_cart.php
*Note: Compate package
MNK,
www.oscommerce-packages.com
This is a rollup of all of the bugfixes and changes mentioned in the support thread. It includes my attempt to reconstruct the 1.1b upload. It also includes Ed's modifications file. This is the complete package.
These 4 changes just provide more info for your customers. They include an info box on your product info pages that links to the Free product and includes a note with the Free item in the shopping catr indicating the item is is Free with ...
Not a complete package, just instructions on 4 file edits.
Hope this is of value to someone.
Great contribution, thanx,
Ed
Fixes
* install.txt - fixed typo and changed 1 line: free_product['image'] to $free_product['image'] and fixed the following line
//if (is_array ($free_product = $this->get1free ($products_id))) {
if (is_array ($free_product = $cart->get1free ($products_id))) {
* upgrade.txt - same
* checkout_process.php - same
* product_info.php - added a class to <p> (.freeproduct) to make individual styling possible. Also updated installation instructions.
Trying again. Apparently the upload of the previous file was borked. Sorry about that.
Updated to include the correct version of shopping_cart.php. All files are included. Please use this one in place of 1.1.
This updated release fixes a number of bugs and adds some new features. See the upgrade.txt file in the distribution or the forum thread for details. Please report any remaining bugs in the forum thread.
This contribution allows you to promote a product by giving a free product when
the customer buys a specified number of the product you are promoting. This is
commonly used for a "buy two, get one free" promotion, but it is more versatile
than that:
* The qualifying quantity of the product you are promoting can be any number,
including one.
* The free product can be the same as the promoted product or any other product
in your catalog.
* You can limit the free product to one per order or any number that you wish.
* Like specials, you can set a date for the offer to expire.
* You can have any number of products in this promotion with different
requirements for each.
The free product is automatically added to the customers shopping cart when they
purchase a qualifying product in the qualifying quantity (or more.) The free
product is removed when the customer removes the qualifying product from their
cart or reduces the quantity below the qualifying quantity. The customer cannot
increase the number of free products without qualifying for them. It's designed
to be fairly foolproof.
The support thread is here:
http://forums.oscommerce.com/index.php?showtopic=255288