Get 1 Free
#281
Posted 18 December 2009, 02:47
==========
New Files:
==========
The following code files are new with this package:
catalog/admin/get_1_free.php
catalog/admin/includes/languages/english/get_1_free.php
catalog/admin/includes/functions/get_1_free.php
catalog/includes/functions/get_1_free.php
However, none of the full versions of this contrib have the "new" file : catalog/admin/includes/functions/get_1_free.php included, I cannot find this file anywhere in any of the downloads of this contrib.
I went ahead and installed the contrib and it seems to work but whats with this missing file? Is this going to work without it?
Anybody know?
Thanks!
Jacson
#282
Posted 18 December 2009, 03:44
It looks like I'm going to have to try to find the time to go clean this thing up. Someday.
Regards
Jim
#283
Posted 18 December 2009, 17:55
Thanks again,
Jacson
#284
Posted 12 March 2010, 06:30
Curious about this addon as im doing a buy 2 get 1 free promotion on my site and seeing if this will do the job.
I havea category, and if a user buys 3 of the products within in, 1 of thoes products will be for free, the one that is the least price of course.
Heres the promo text, "Buy 2 get 1 free, of equal or lesser value"
Thanks
#285
Posted 13 March 2010, 08:54
i am using this adon..
the problem is i am using another product which i put into zero?
i would like to hide the product so it wont show on product list and bestseller and if itl be opened i would like to disable the add to cart and buy now button? its troubling me coz it shows up in the best seller i have it appearing on on all of my product as buy 1 take one?
any sugested mod?
0
#286
Posted 16 March 2010, 23:55
halluzineyt, on 13 March 2010, 08:54, said:
i am using this adon..
the problem is i am using another product which i put into zero?
i would like to hide the product so it wont show on product list and bestseller and if itl be opened i would like to disable the add to cart and buy now button? its troubling me coz it shows up in the best seller i have it appearing on on all of my product as buy 1 take one?
any sugested mod?
0
in checkout_process.php
find
// comment out the next line if you don't want free products in the bestseller list
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
now change it too
// comment out the next line if you don't want free products in the bestseller list
// tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
it will no longer be added to best sellers to remove it from best sellers table use phpmyadmin click on products table find products_ordered filed for that product now click on the pencil icon and edit it
Steve
#287
Posted 16 March 2010, 23:58
Island101, on 12 March 2010, 06:30, said:
Curious about this addon as im doing a buy 2 get 1 free promotion on my site and seeing if this will do the job.
I havea category, and if a user buys 3 of the products within in, 1 of thoes products will be for free, the one that is the least price of course.
Heres the promo text, "Buy 2 get 1 free, of equal or lesser value"
Thanks
This is buy x amount get y amount free, you have to assign what product will be free in admin, user cant buy 1 product and get any product he chooses of same amount or less free
Steve
#288
Posted 18 March 2010, 10:28
Thanks for this mod Kymation
Is there any way to somehow enable the free product to have colour / style / size selection capability?
At the moment - I am asking people to tell me what style and colour of the freebie they want in the comments box, but of course, this is pretty annoying as some people forget or choose an option that's out of stock!
Anyone know a way to achieve this?
Thanks
#289
Posted 18 March 2010, 15:38
Regards
Jim
#290
Posted 18 March 2010, 23:21
steve_s, on 16 March 2010, 23:58, said:
This is buy x amount get y amount free, you have to assign what product will be free in admin, user cant buy 1 product and get any product he chooses of same amount or less free
Steve
Ah ok, thanks steve. Any idea of a contrib that allows me to do that?
ive been looking around for a while no with no avail.
#291
Posted 20 March 2010, 11:23
Island101, on 18 March 2010, 23:21, said:
ive been looking around for a while no with no avail.
Steve
#292
Posted 25 March 2010, 10:39
steve_s, on 16 March 2010, 23:55, said:
in checkout_process.php
find
// comment out the next line if you don't want free products in the bestseller list
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
now change it too
// comment out the next line if you don't want free products in the bestseller list
// tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
it will no longer be added to best sellers to remove it from best sellers table use phpmyadmin click on products table find products_ordered filed for that product now click on the pencil icon and edit it
Steve
#293
Posted 25 March 2010, 11:32
steve_s, on 16 March 2010, 23:55, said:
in checkout_process.php
find
// comment out the next line if you don't want free products in the bestseller list
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
now change it too
// comment out the next line if you don't want free products in the bestseller list
// tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
it will no longer be added to best sellers to remove it from best sellers table use phpmyadmin click on products table find products_ordered filed for that product now click on the pencil icon and edit it
Steve
whoaahh sorry but its not on my file
Quote
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
this part.. now i got some problems the orders.php record the order but the details of the customer is not there just the price and postage.. when i looked at the database its there what part of the installation could have caused this..
[img]http://img291.imageshack.us/img291/7561/testco.png[/img]
#294
Posted 25 March 2010, 14:10
but my free products still adds on the database will it still be seen on bestsellers?
#295
Posted 19 April 2010, 20:39
When I look at the database the free item is there as part of the order, but the admin is not reflecting it.
#296
Posted 19 April 2010, 20:49
Regards
Jim
#297
Posted 02 August 2010, 17:19
I think that it's better to say the customer that it's an offer for this item, that into all listings.
So i have this script into catalog/product_listing.php:
if(tep_db_num_rows(tep_db_query("select products_id, get_1_free_expires_date, status from " . TABLE_GET_1_FREE . " where products_id = '" . (int)$listing['products_id'] . "' and get_1_free_expires_date>now() and status = '1'")))
{
$lc_text .= '<span style="color:#ee5500; font-weight:bold;">'.TEXT_GET_1_FREE_PUB.'</span>';
}
break;
and a similar into catalog/products_new.php with adaptation for the variables names ($products_new['products_id'] & $products_new['name'] instead $listing['products_id'] & $lc_text respectivelyI have put TEXT_GET_1_FREE_PUB define into catalog/includes/languages/french/index.php :
define('TEXT_GET_1_FREE_PUB', '<br>En ce moment, un Cadeau !');
that you can translate easely into your language & put it into catalog/includes/languages/<your language>/index.phpIn the same way, i have modified catalog/product_info.php & catalog/includes/languages/french/product_info.php to give last date:
if (tep_db_num_rows($get_1_free_query) > 0) {
$free_product = tep_db_fetch_array($get_1_free_query);
$exp=explode('-',substr($free_product['get_1_free_expires_date'], 0, strpos($free_product['get_1_free_expires_date'], ' ')));
$jour=$exp['2'];
$mois=$exp['1'];
$an=$exp['0'];
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'],$jour,$mois,$an) . '</p>';
}
// end Get 1 Free
french define:// Get 1 Free
define('TEXT_GET_1_FREE_PROMOTION', '<span style="color:#ee5500; font-weight:bold;">Offre Spéciale limitée:<br>Acheté : %u %s<br>Cadeau : %u %s Gratis ! <br></span><span style="text-decoration:underline;">ATTENTION </span>: Offre valable jusqu\'au <span style="font-weight:bold;">%s/%s/%s !</span>');
that you can translate easely into your language & put it into catalog/includes/languages/<your language>/index.php.Keep care to the %s for the dates (Y/m/d in english, d/m/Y in french usw.
Had anyone something better, it's interessing to read.
A pretty day to all !
Chti poupon
#298
Posted 27 August 2010, 02:04
There is a fantastic addition to this add on by dmordred in the contributions page.
It puts a link on the main product - to the free product and it works great.
However, it would be nice to be able to display a message in the free product description page that links to the main product?
At the moment, I can't see how to do this.
Any suggestions?
Thanks
#299
Posted 05 September 2010, 20:21
I don't see too ! Why give that customer buy directly !
I have worked another way.
So, why can we not prepare this promotions ?
There is no begining date.
But admin/banner.php has ! This give that:
Calendar for shedule & expiration dates for get_1_free
Modified files to obtain:
admin/get_1_free.php
case 'insert':
$products_id = tep_db_prepare_input($_POST['products_id']);
$products_free_id = tep_db_prepare_input($_POST['products_free_id']);
$products_free_quantity = tep_db_prepare_input($_POST['products_free_quantity']);
$products_qualify_quantity = tep_db_prepare_input($_POST['products_qualify_quantity']);
$products_multiple = tep_db_prepare_input($_POST['products_multiple']);
$get_1_free_sheduled_date = tep_db_prepare_input($_POST['get_1_free_sheduled_date']);
$get_1_free_expires_date = tep_db_prepare_input($_POST['get_1_free_expires_date']);
tep_db_query("insert into " . TABLE_GET_1_FREE . "
(products_id,
products_free_id,
products_free_quantity,
products_qualify_quantity,
products_multiple,
get_1_free_date_added,
get_1_free_sheduled_date,
get_1_free_expires_date,
status)
values ('" . (int)$products_id . "',
'" . tep_db_input($products_free_id) . "',
'" . tep_db_input($products_free_quantity) . "',
'" . tep_db_input($products_qualify_quantity) . "',
'" . tep_db_input($products_multiple) . "',
now(),
'" . tep_db_input($get_1_free_sheduled_date) . "',
'" . tep_db_input($get_1_free_expires_date) . "',
'1')"
);
case 'update':
$get_1_free_id = tep_db_prepare_input($_POST['get_1_free_id']);
$products_id = tep_db_prepare_input($_POST['products_id']);
$products_free_id = tep_db_prepare_input($_POST['products_free_id']);
$products_free_quantity = tep_db_prepare_input($_POST['products_free_quantity']);
$products_qualify_quantity = tep_db_prepare_input($_POST['products_qualify_quantity']);
$products_multiple = tep_db_prepare_input($_POST['products_multiple']);
$get_1_free_sheduled_date = tep_db_prepare_input($_POST['get_1_free_sheduled_date']);
$get_1_free_expires_date = tep_db_prepare_input($_POST['get_1_free_expires_date']);
tep_db_query("update " . TABLE_GET_1_FREE . "
set products_free_id = '" . tep_db_input($products_free_id) . "',
products_free_quantity = '" . tep_db_input($products_free_quantity) . "',
products_free_quantity = '" . tep_db_input($products_free_quantity) . "',
products_qualify_quantity = '" . tep_db_input($products_qualify_quantity) . "',
products_multiple = '" . tep_db_input($products_multiple) . "',
get_1_free_last_modified = now(),
get_1_free_sheduled_date = '" . $get_1_free_sheduled_date . "',
get_1_free_expires_date = '" . $get_1_free_expires_date . "'
where get_1_free_id = '" . (int)$get_1_free_id . "'"
);
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="javascript"><!--
var dateSheduled = new ctlSpiffyCalendarBox("dateSheduled", "new_get_1_free", "get_1_free_sheduled_date","btnDate","<?php echo $fInfo->get_1_free_sheduled_date; ?>",scBTNMODE_CUSTOMBLUE);
var dateExpires = new ctlSpiffyCalendarBox("dateExpires", "new_get_1_free", "get_1_free_expires_date","btnDate","<?php echo $fInfo->get_1_free_expires_date; ?>",scBTNMODE_CUSTOMBLUE);
//-->
</script>
<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
$form_action = 'update';
$product_qualify_query = tep_db_query("select p.products_id,
pd.products_name,
g1f.products_free_id,
g1f.products_free_quantity,
g1f.products_qualify_quantity,
g1f.products_multiple,
g1f.status,
g1f.get_1_free_sheduled_date,
g1f.get_1_free_expires_date
from " . TABLE_PRODUCTS . " p,
" . TABLE_PRODUCTS_DESCRIPTION . " pd,
" . TABLE_GET_1_FREE . " g1f
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$languages_id . "'
and p.products_id = g1f.products_id
and g1f.get_1_free_id = '" . (int)$_GET['fID'] . "'"
);
<td class="main"><?php echo tep_draw_input_field('products_free_quantity', (isset($fInfo->products_free_quantity) ? $fInfo->products_free_quantity : '')); ?></td>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_INFO_SHEDULED_DATE; ?><br><small>(dd/mm/yyyy)</small></td>
<td valign="top" class="main"><script language="javascript">dateSheduled.writeControl(); dateSheduled.dateFormat="yyyy-MM-dd";</script></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td valign="top" class="main"><?php echo TEXT_INFO_EXPIRES_DATE; ?><br><small>(dd/mm/yyyy)</small></td>
<td class="main"><script language="javascript">dateExpires.writeControl(); dateExpires.dateFormat="yyyy-MM-dd";</script></td>
</tr>
</table></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><br><?php echo TEXT_GET_1_FREE_PRICE_TIP; ?></td>
<td class="main" align="right" valign="top"><br><?php echo (($form_action == 'insert') ? tep_image_submit('button_insert.gif', IMAGE_INSERT) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). ' <a href="' . tep_href_link(FILENAME_GET_1_FREE, 'page=' . $_GET['page'] . (isset($_GET['fID']) ? '&fID=' . $_GET['fID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
</tr>
</table></td>
</form></tr>
TABLE_HEADING_ACTION; ?> </td>
</tr>
<?php
$get_1_free_query_raw = "select p.products_id,
pd.products_name,
p.products_price,
g1f.get_1_free_id,
g1f.products_free_id,
g1f.products_free_quantity,
g1f.products_qualify_quantity,
g1f.products_multiple,
g1f.get_1_free_date_added,
g1f.get_1_free_last_modified,
g1f.get_1_free_sheduled_date,
g1f.get_1_free_expires_date,
g1f.date_status_change,
g1f.status
from " . TABLE_PRODUCTS . " p,
" . TABLE_GET_1_FREE . " g1f,
" . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$languages_id . "'
and p.products_id = g1f.products_id
order by pd.products_name";
$get_1_free_split = new splitPageResults($_GET['page'],
fInfo->products_multiple);
$contents[] = array('text' => '<br>' . TEXT_INFO_PRODUCTS_FREE . ' ' . $product_free['products_name']);
$contents[] = array('text' => '' . TEXT_INFO_PRODUCTS_FREE_QUANTITY . ' ' . $fInfo->products_free_quantity);
$contents[] = array('text' => '<br>' . TEXT_INFO_SHEDULED_DATE . ' <b>' . tep_date_short($fInfo->get_1_free_sheduled_date) . '</b>');
$contents[] = array('text' => '<br>' . TEXT_INFO_EXPIRES_DATE . ' <b>' . tep_date_short($fInfo->get_1_free_expires_date) . '</b>');
$contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . tep_date_short($fInfo->date_status_change));
}
break;
}
if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
admin/includes/languages/<your language>/get_1_free.php
define('TEXT_INFO_SHEDULED_DATE', 'Begins At:');
define('TEXT_INFO_EXPIRES_DATE', 'Expires At:');
catalog/product_info.php// start Get 1 Free
// Display promotional text if this product qualifies for free product(s)
$get_1_free_query = tep_db_query("select pd.products_name,
g1f.products_free_quantity,
g1f.products_qualify_quantity,
g1f.get_1_free_sheduled_date,
g1f.get_1_free_expires_date
from " . TABLE_GET_1_FREE . " g1f,
" . TABLE_PRODUCTS_DESCRIPTION . " pd
where g1f.products_id = '" . (int)$product_info['products_id'] . "'
and pd.products_id = g1f. products_free_id
and g1f.get_1_free_sheduled_date < now()
and (g1f.get_1_free_expires_date > now()
or g1f.get_1_free_expires_date = 0 )
and pd.language_id = '" . (int)$languages_id . "'
and status = '1'"
);
if (tep_db_num_rows($get_1_free_query) > 0) {
$free_product = tep_db_fetch_array($get_1_free_query);
$exp=explode('-',substr($free_product['get_1_free_expires_date'], 0, strpos($free_product['get_1_free_expires_date'], ' ')));
$jour=$exp['2'];
$mois=$exp['1'];
$an=$exp['0'];
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'],$jour,$mois,$an) . '</p>';
}
// end Get 1 Free?>
<?php echo stripslashes($product_info['products_description']); ?>
catalog/includes/modules/product_listing.phpif(tep_db_num_rows(tep_db_query("select products_id, get_1_free_sheduled_date, get_1_free_expires_date, status from " . TABLE_GET_1_FREE . " where products_id = '" . (int)$listing['products_id'] . "' and get_1_free_sheduled_date < now() and (get_1_free_expires_date > now() or get_1_free_expires_date = 0 ) and status = '1'")))
{
$lc_text .= '<span style="color:#ee5500; font-weight:bold;">'.TEXT_GET_1_FREE_PUB.'</span>';
}
break;
case 'PRODUCT_LIST_MANUFACTURER':
catalog/includes/application_top.php
// auto activate and expire banners
require(DIR_WS_FUNCTIONS . 'banner.php');
tep_activate_banners();
tep_expire_banners();
// auto expire special products
require(DIR_WS_FUNCTIONS . 'specials.php');
tep_expire_specials();
// auto activeta & expire get_1_free products
require(DIR_WS_FUNCTIONS . 'get_1_free.php');
tep_activate_get_1_free();
tep_expire_get_1_free();
// calculate category path
if (isset($_GET['cPath'])) {
and finally:
catalog/includes/functions/get_1_free.php
}
// Auto activate get_1_free
function tep_activate_get_1_free() {
$get_1_free_query = tep_db_query("select get_1_free_id, get_1_free_sheduled_date from " . TABLE_GET_1_FREE . " where get_1_free_sheduled_date != ''");
if (tep_db_num_rows($get_1_free_query)) {
while ($get_1_free = tep_db_fetch_array($get_1_free_query)) {
if (date('Y-m-d H:i:s') >= $get_1_free['get_1_free_sheduled_date']) {
tep_set_get_1_free_status($get_1_free['get_1_free_id'], '1');
}
}
}
}
////
?>
This works, etablish automatically pubs & wipes when obsoletes.
Enjoy !
bebe cash 59
Edited by bebe cash 59, 05 September 2010, 20:22.
#300
Posted 05 September 2010, 20:31
Another problem:
When we edit a product in admin get_1_free, the offer becomes the first in alphabetical order !!! Whet a garbage if we sleep a little !
Here are modifications to preselect the previous choice into the drop list:
modify the files to obtain:
catalog/admin/includes/functions/general.php
function tep_draw_products_pull_down($name, $parameters = '', $exclude = '',$selected_id='') {
global $currencies, $languages_id;
if ($exclude == '') {
$exclude = array();
}
$select_string = '<select name="' . $name . '"';
if ($parameters) {
$select_string .= ' ' . $parameters;
}
$select_string .= '>';
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");
while ($products = tep_db_fetch_array($products_query)) {
if (!in_array($products['products_id'], $exclude)) {
$select_string .= '<option value="' . $products['products_id'].'"'. ($selected_id==$products['products_id'] ? 'selected="selected"':'').'>' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';
}
}
$select_string .= '</select>';
return $select_string;
}
and
catalog/admin/get_1_free.php
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_GET_1_FREE_PRODUCTS_FREE; ?> </td>
<td class="main"><?php echo tep_draw_products_pull_down('products_free_id','style="font-size:10px"','',(isset($fInfo->products_free_id) ? $fInfo->products_free_id : '')); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_GET_1_FREE_PRODUCTS_FREE_QUANTITY; ?> </td>
That's all Folks
bebe cash 59














