Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 1 votes

Get 1 Free


345 replies to this topic

#281 Jacson

  • Community Member
  • 40 posts
  • Real Name:Jac Grant

Posted 18 December 2009, 02:47

Hi All - great contrib, seems to work so far perfectly but I am baffled by one major thing, the latter "full versions" have this in the install instructions:

==========
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 kymation

  • Community Sponsor
  • 5,285 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 18 December 2009, 03:44

You only need it if the Admin fails without it. I don't believe that it does, but I haven't tried it. If you do need it, the file should be just a copy of the one from the Catalog side.

It looks like I'm going to have to try to find the time to go clean this thing up. Someday.

Regards
Jim

#283 Jacson

  • Community Member
  • 40 posts
  • Real Name:Jac Grant

Posted 18 December 2009, 17:55

Hi Jim - Thanks for the reply! Mine works great, so I guess I did not need it. All I suggest is that you put a note or something in the install instructions about it as it is confusing....

Thanks again,

Jacson

#284 Island101

  • Community Member
  • 20 posts
  • Real Name:Lyle

Posted 12 March 2010, 06:30

Hi,
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 halluzineyt

  • Community Member
  • 184 posts
  • Real Name:jayson

Posted 13 March 2010, 08:54

Hello i hope somebody can read my post eventough this is an old mod..

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 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 16 March 2010, 23:55

View Posthalluzineyt, on 13 March 2010, 08:54, said:

Hello i hope somebody can read my post eventough this is an old mod..

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
Hi

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 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 16 March 2010, 23:58

View PostIsland101, on 12 March 2010, 06:30, said:

Hi,
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
Hi,

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 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 18 March 2010, 10:28

Hello good people of the planet OSC!

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 kymation

  • Community Sponsor
  • 5,285 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 18 March 2010, 15:38

Other than the method given in the instructions, no.

Regards
Jim

#290 Island101

  • Community Member
  • 20 posts
  • Real Name:Lyle

Posted 18 March 2010, 23:21

View Poststeve_s, on 16 March 2010, 23:58, said:

Hi,

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 steve_s

  • Community Member
  • 1,580 posts
  • Real Name:steve
  • Gender:Male
  • Location:London

Posted 20 March 2010, 11:23

View PostIsland101, on 18 March 2010, 23:21, said:

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.
There s no contribution that i know, off get 1 free could be altered to do that, but you would have to hire a php coder for that

Steve

#292 halluzineyt

  • Community Member
  • 184 posts
  • Real Name:jayson

Posted 25 March 2010, 10:39

View Poststeve_s, on 16 March 2010, 23:55, said:

Hi

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
thaaaannnkkksss!!!!

#293 halluzineyt

  • Community Member
  • 184 posts
  • Real Name:jayson

Posted 25 March 2010, 11:32

View Poststeve_s, on 16 March 2010, 23:55, said:

Hi

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

// 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']) . "'");

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 halluzineyt

  • Community Member
  • 184 posts
  • Real Name:jayson

Posted 25 March 2010, 14:10

sorry for my last post but i have fixed it now..

but my free products still adds on the database will it still be seen on bestsellers?

#295 gwynwyffar

  • Community Member
  • 58 posts
  • Real Name:Jennifer Cristaldi
  • Gender:Female
  • Location:Hudson Valley, NY

Posted 19 April 2010, 20:39

I'm having a strange issue with this contribution and I expect it has something to do with the MVS shipping mod I also have installed. Everything works on the customer's end, it adds the free item, the item shows up properly all through the checkout process and even on the customer's order confirmation email, however when I view the order on the admin side it does not show the free item as part of the order at all, not on the order, the invoice or the packing slip. The only thing that it shows the customer ordered is the item they would have paid full price for. Has anyone else encountered this issue? Any insight as to where I might look to fix this?

When I look at the database the free item is there as part of the order, but the admin is not reflecting it.

#296 kymation

  • Community Sponsor
  • 5,285 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 April 2010, 20:49

It sounds like you have an error of some kind in your Admin code. The product should show up if it's in the database. I have this installed in a store with MVS and it works fine. You'll just have to follow the data from the database to your Admin pages.

Regards
Jim

#297 bebe cash 59

  • Community Member
  • 8 posts
  • Real Name:Dremierre

Posted 02 August 2010, 17:19

Hello !
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 respectively

I 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.php

In 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 ssnb

  • Community Member
  • 278 posts
  • Real Name:Sol
  • Gender:Male
  • Location:Auckland, New Zealand

Posted 27 August 2010, 02:04

Hi All

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 bebe cash 59

  • Community Member
  • 8 posts
  • Real Name:Dremierre

Posted 05 September 2010, 20:21

Hi !
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)). '&nbsp;&nbsp;&nbsp;<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; ?>&nbsp;</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.php
if(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 bebe cash 59

  • Community Member
  • 8 posts
  • Real Name:Dremierre

Posted 05 September 2010, 20:31

Hi !
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; ?>&nbsp;</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; ?>&nbsp;</td>

That's all Folks

bebe cash 59