♥kymation Posted November 23, 2007 Author Share Posted November 23, 2007 Hi there, I like the idea of your Add-On. However, when I tried to manually install the add-on it went wrong and did not work, so I reverted to a previously saved version of my site. However, when I reverted the changed files, I get the following error message where the application_bottom.php file should be displayed...any suggestions from anyone would be much appreciated. 1146 - Table 'toptoners.TABLE_COUNTER' doesn't exist select startdate, counter from TABLE_COUNTER [TEP STOP] Thank you. Mark. http://www.toptoners.co.uk/catalog/ You may have forgotten to revert the catalog/includes/database_tables.php, or somehow messed up that file. That table definition should be in any version of osCommerce, so I'm thinking it may have been accidentally deleted. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
consolidated Posted November 24, 2007 Share Posted November 24, 2007 (edited) Hi there, Thank you for that...it worked! However, when I go to my admin it works, until I click onto a sub-section, when I get a 404 Not Found error "The requested URL was not found on this server." Any ideas what could have gone wrong and any suggestions to fix it would be much appreciated. Mark. Edited November 27, 2007 by Jan Zonjee Quote Link to comment Share on other sites More sharing options...
♥kymation Posted November 24, 2007 Author Share Posted November 24, 2007 (edited) Hi there, Thank you for that...it worked! However, when I go to my admin it works, until I click onto a sub-section, when I get a 404 Not Found error "The requested URL was not found on this server." Any ideas what could have gone wrong and any suggestions to fix it would be much appreciated. Mark. Given the cause of the previous problem, I would guess that admin/includes/filenames.php is corrupted or missing. If that's not it, problems with admin/includes/configuration.php. Regards Jim Edited November 27, 2007 by Jan Zonjee Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
aidemmedia Posted November 27, 2007 Share Posted November 27, 2007 Hi Jim Your contribution is really great. I've got one suggestion for it. In Poland due to tax law we cannot give smth for free. It can be 1 cent, but not completly free. I guess you can add simple solution to set the price in the module - to 0$ or more for some other cases. And besides it would widen this solution to actions like: Buy X get 1 for 10$. Hope it's possible. Regards Mac Quote Link to comment Share on other sites More sharing options...
Guest Posted November 27, 2007 Share Posted November 27, 2007 This looks great - does anyone know if this works Ok with CRE loaded? Thanks Bob Quote Link to comment Share on other sites More sharing options...
♥kymation Posted November 27, 2007 Author Share Posted November 27, 2007 Maciej: I'd never heard that one before. I know of places where the value of a free gift is limited, but not that it was forbidden. Of course you can just set the value in the shopping cart class for now. I'll add a variable price to the wish list for the next release. Bob: It should work with a bit of adaptation. The line numbers will be off, and there will need to be modifications to the notice on the product info page for it to look right. I haven't actually tried this, but I have added this to several heavily modified stores without serious problems, so your modified store should work as well. Please post here if you have any other problems and we'll try to figure it out. I would also like to know if you get this to work, in case of future questions. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
binkycrafts Posted November 30, 2007 Share Posted November 30, 2007 Hi, this contribution looks great but if I am reading it correctly I dont think it is what I am looking for and maybe what I need is not out there. I have a category of products that are on sale at buy 1 get one free but this applies to the whole category, ie you can choose 1 of x and get 1 of y for free or to put it another way, if you add 2 items from one specific category to your basket you will only be charged for 1. As I read it, this contrib workes per product and not category but please advise if I am mistaken or if anyone can point me to something that can help. Many thanks, Binky. Quote Tony Link to comment Share on other sites More sharing options...
flom Posted November 30, 2007 Share Posted November 30, 2007 Thanks for the patch. That does the job nicely. I was thinking of something much more complicated. Typical; I tend to over-design things. Now I just need to package up all of the fixes everyone has contributed and put out a new release. If anyone knows of more bugs, now would be a great time to speak up. Regards Jim Maybe a little late but I made another fix. Please see contributions. It is now possible to make standard settings for new date. Furthermore now when editing the correct data will be displayed. Have Fun. :) Quote Link to comment Share on other sites More sharing options...
♥kymation Posted November 30, 2007 Author Share Posted November 30, 2007 Tony: I don't know of any contribution that does what you want. That doesn't mean there isn't one; I don't know everything. I would suggest a careful search of the Contributions section, just in case. flo: Thanks for another fix. I always appreciate anyone that contributes their improvements back to the group. That reminds me -- I have an upgrade to another Contribution that I need to put up. Better get busy.... Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
aidemmedia Posted December 3, 2007 Share Posted December 3, 2007 Hello again I got the problem with module sending email - there were no info about Free Gift i just added the following content in checkout_process.php: After the lines (around line 254): $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n"; I've added lines: if ($cart->show_total()>=FREE_GIFT_MINIMUM_SPEND) { $freegift_query = tep_db_query("select products_name from products_description where products_id = '" . $cart->get_freegift() . "'"); $freegift = tep_db_fetch_array($freegift_query); $email_order .= "Your free gift : " . $freegift['products_name'] . "\n" . EMAIL_SEPARATOR . "\n"; } And I'm experiencing some troubles with account history - it's blank after ordering Free Gift. Not sure if it is the contribution problem or my system. I got just one more question as I'm really lame with composed sql syntax. $freegifts_query = tep_db_query("SELECT products.products_id, products_description.products_name FROM products Inner Join products_to_categories ON products.products_id = products_to_categories.products_id Inner Join products_description ON products.products_id = products_description.products_id WHERE products_to_categories.categories_id = '". FREE_GIFT_CATEGORY . "'"); I'm trying to change the conditions of Free Gift - not by the category id but all products under specific price and with specific language. table - products_description, field - language_id and table - products, field - products.price I know it's a while for you ;). Best Regards Maciej Quote Link to comment Share on other sites More sharing options...
aidemmedia Posted December 4, 2007 Share Posted December 4, 2007 Hi I've got the problem solved with query, it was so easy that I'm ashamed a bit :). But still I've got problems with account history - it is blank. Have you noticed similiar problem ?? Regards Maciej Quote Link to comment Share on other sites More sharing options...
♥kymation Posted December 5, 2007 Author Share Posted December 5, 2007 Good idea to add the text to the email -- I forgot about that. I haven't seen any problem with account history. Check the page source -- is it truly blank or is there a hidden error message? If it's completely blank, check your error logs if possible. If there is an error there, it's most likely something in catalog/includes/classes/shopping_cart.php, so you might want to take a close look at your changes there. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Darky10 Posted December 5, 2007 Share Posted December 5, 2007 Is it possible to allow a free gift on all items in catalog? it would take ages to do it single Quote Link to comment Share on other sites More sharing options...
♥kymation Posted December 5, 2007 Author Share Posted December 5, 2007 Is it possible to allow a free gift on all items in catalog? it would take ages to do it single That would be a bit of work, depending on how many products you have. Perhaps you could use this contribution and just set the price limit really low. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2007 Share Posted December 10, 2007 This looks great - does anyone know if this works Ok with CRE loaded? Thanks Bob Hi I am now adding this - I have decided to add the code manually. First problem is that the catalog/product_info.php file does not have any of the code listed in the install instructions below. <p><?php echo stripslashes($product_info['products_description']); ?></p> <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); I have done a site wide search using dreamweaver and I do not have this code. My product_info.php file is as follows: <?php /* $Id: product_info.php,v 1.1.1.1 2004/03/04 23:38:02 ccwjr Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO); $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); //check if product is really a subproduct $product_sub_product_query = tep_db_query("select products_parent_id from " . TABLE_PRODUCTS . " p where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); while ($product_sub_product = tep_db_fetch_array($product_sub_product_query)){ $product_sub_check = $product_sub_product['products_parent_id']; } if ($product_sub_check > 0){ tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_sub_check)); } //check to see if products have sub_products $product_has_sub = '0'; $sub_products_sql1 = tep_db_query("select p.products_id, p.products_price, p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_parent_id = " . (int)$HTTP_GET_VARS['products_id'] . " and p.products_quantity > '0' and p.products_id = pd.products_id and pd.language_id = " . (int)$languages_id); if (tep_db_num_rows($sub_products_sql1) > 0) { $product_has_sub = '1'; }else{ $product_has_sub = '0'; } $content = CONTENT_PRODUCT_INFO; $javascript = 'popup_window.js'; require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Any help would be appreciated Bob Quote Link to comment Share on other sites More sharing options...
♥kymation Posted December 10, 2007 Author Share Posted December 10, 2007 Hi I am now adding this - I have decided to add the code manually. First problem is that the catalog/product_info.php file does not have any of the code listed in the install instructions below. <code snipped> Any help would be appreciated Bob The addition to catalog/product_info.php just adds some text to the page describing the special offer. You could probably add that to your template file, wherever you want it to appear on the page. I'm not familiar enough with your modified store to say exactly where that should be, but you can probably figure it out. As an alternative, you could skip this step and just add some text to the description of the products affected by this offer. You would need to remember to change the description when the offer ends, otherwise the result would be the same. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
deaconest Posted December 14, 2007 Share Posted December 14, 2007 Just wanted to thank you for this contribution. And to see when it might get updated to 5.0 compatable for mysql querries.. This will be a great contribution to add to my site. When I can get it working. Thanks again.. Quote Link to comment Share on other sites More sharing options...
♥kymation Posted December 14, 2007 Author Share Posted December 14, 2007 Just wanted to thank you for this contribution. And to see when it might get updated to 5.0 compatable for mysql querries.. This will be a great contribution to add to my site. When I can get it working. Thanks again.. I won't be changing the queries until I get a copy of MySQL 5.x to play with. Until then, anybody who can test updated queries is welcome to do so. Please post the results here. Ideally, I'd like to have one version that works for everyone, if that's even possible. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Guest Posted February 8, 2008 Share Posted February 8, 2008 Hi I am now adding this - I have decided to add the code manually. First problem is that the catalog/product_info.php file does not have any of the code listed in the install instructions below. <p><?php echo stripslashes($product_info['products_description']); ?></p> <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); I have done a site wide search using dreamweaver and I do not have this code. My product_info.php file is as follows: <?php /* $Id: product_info.php,v 1.1.1.1 2004/03/04 23:38:02 ccwjr Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO); $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); //check if product is really a subproduct $product_sub_product_query = tep_db_query("select products_parent_id from " . TABLE_PRODUCTS . " p where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); while ($product_sub_product = tep_db_fetch_array($product_sub_product_query)){ $product_sub_check = $product_sub_product['products_parent_id']; } if ($product_sub_check > 0){ tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_sub_check)); } //check to see if products have sub_products $product_has_sub = '0'; $sub_products_sql1 = tep_db_query("select p.products_id, p.products_price, p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_parent_id = " . (int)$HTTP_GET_VARS['products_id'] . " and p.products_quantity > '0' and p.products_id = pd.products_id and pd.language_id = " . (int)$languages_id); if (tep_db_num_rows($sub_products_sql1) > 0) { $product_has_sub = '1'; }else{ $product_has_sub = '0'; } $content = CONTENT_PRODUCT_INFO; $javascript = 'popup_window.js'; require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Any help would be appreciated Bob OK - I have now figured this out. Amended install intructions are below with additional notes for CRE loaded installation ver 6.2 pro V11. You can see it working on www.mbstore.co.uk. The main problem is that a lot of the files are in the templates folder and have different names. It works great but it would be nice to see something on the home page to promote it! I have simply added another category and copied products to there. Bob Modified install.txt ============================================================== Get 1 Free v 1.1 2007/03/21 Jim Keebaugh osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2007 osCommerce Released under the GNU General Public License For the terms of this license please see the file gpl.txt included in this distribution ============================================================== =========== Text Files: =========== The following text files are included with this package: readme.txt (introduction) install.txt (installation instructions) upgrade.txt (instructions for upgrading from a previous version) use.txt (instructions for using this Contribution) Get 1 Free Mods.txt (instructions for improving messages to the customer) gpl.txt (your license) ========== 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 =============== Modified Files: =============== The following files have been modified from stock osCommerce: catalog/admin/includes/database_tables.php catalog/admin/includes/filenames.php catalog/admin/includes/boxes/catalog.php catalog/admin/includes/languages/english.php catalog/checkout_process.php catalog/product_info.php catalog/shopping_cart.php catalog/includes/application_top.php catalog/includes/database_tables.php catalog/includes/classes/shopping_cart.php catalog/includes/languages/english/product_info.php ============= Installation: ============= Copy all of the files listed under New Files above to the appropriate directory in your osCommerce installation. These instructions assume that your osCommerce is installed in the default Catalog directory, and that the admin is in catalog/admin. If these have been moved to different locations in your installation, adjust these instructions to suit your installation. If you are running osCommerce 2.2 MS2, and you have not yet made any changes to those stock files, you can copy the files listed in the Modified Files section above and proceed to the use.txt file. If you are running 2.2rc1, I suggest that you check the file headers before overwriting any of the stock files. If the file hase a different date and/or version number, or the part after $Id: is blank, I suggest that you patch these files by hand. Overwriting a newer file with an older one can cause unexpected problems. If you have changed some of the files, you can still copy over any of these that you have not yet modified. The ones that you have modified will need to be further modified per the Modify Files section below. ========= Database: ========= This Contribution adds a table to the database. To add this table, run the get_1_free.sql file in this distribution from your database admin tool, or run the instructions in that file from the MySQL command line. You can also create the table manually in your admin tool using the file as a template. ================ CRE Loaded Notes ================ The notes regarding installation on CRE loaded relate to CRE loaded 6.2 Pro V11 ============= Modify Files: ============= If you have previously modified some of the files listed in the Modified Files section above, or you are adding this contribution to a copy of osCommerce 2.2rc1, follow the instructions here to modify those files for this Contribution. First, open catalog/admin/includes/database_tables.php and find the following code [starting around line 27]: --------------------------------------------------------------------------------------- define('TABLE_CUSTOMERS_INFO', 'customers_info'); --------------------------------------------------------------------------------------- and add this just after it: --------------------------------------------------------------------------------------- // Get 1 Free define('TABLE_GET_1_FREE', 'get_1_free'); --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/admin/includes/filenames.php and find the following code [starting around line 27]: --------------------------------------------------------------------------------------- define('FILENAME_GEO_ZONES', 'geo_zones.php'); --------------------------------------------------------------------------------------- and add this just after it: --------------------------------------------------------------------------------------- // Get 1 Free define('FILENAME_GET_1_FREE', 'get_1_free.php'); --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/admin/includes/boxes/catalog.php and find the following code [starting around line 29]: =========================== CRE Loaded modification will be Find tep_admin_files_boxes(FILENAME_PRODUCTS_EXPECTED, BOX_CATALOG_PRODUCTS_EXPECTED) . Add this line just after the above tep_admin_files_boxes(FILENAME_GET_1_FREE, BOX_CATALOG_GET_1_FREE) . =========================== --------------------------------------------------------------------------------------- '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a>'); --------------------------------------------------------------------------------------- and replace it with this: --------------------------------------------------------------------------------------- '<a href="' . tep_href_link(FILENAME_PRODUCTS_EXPECTED, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_PRODUCTS_EXPECTED . '</a><br>' . '<a href="' . tep_href_link(FILENAME_GET_1_FREE, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_GET_1_FREE . '</a>'); --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/admin/includes/languages/english.php and find the following code [around line 77]: --------------------------------------------------------------------------------------- define('BOX_CATALOG_PRODUCTS_EXPECTED', 'Products Expected'); --------------------------------------------------------------------------------------- and add this just after it: --------------------------------------------------------------------------------------- // Get 1 Free define('BOX_CATALOG_GET_1_FREE', 'Get 1 Free'); --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/checkout_process.php and find the following code [around line 214]: --------------------------------------------------------------------------------------- //------insert customer choosen option eof ---- $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']); $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty']; $total_cost += $total_products_price; $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n"; --------------------------------------------------------------------------------------- and add this just after it: --------------------------------------------------------------------------------------- // start Get 1 free // If this product qualifies for free product(s) add the free products if (is_array ($free_product = $cart->get1free ($products_id))) { // Update products_ordered (for bestsellers list) // 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']) . "'"); $sql_data_array = array('orders_id' => $insert_id, 'products_id' => $free_product['id'], 'products_model' => $free_product['model'], 'products_name' => $free_product['name'], 'products_price' => 0, 'final_price' => 0, 'products_tax' => '', 'products_quantity' => $free_product['quantity'] ); tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array); $total_weight += ($free_product['quantity'] * $free_product['weight']); } // end Get 1 free --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/product_info.php and find the following code [around line 120]: ============= (CRE Loaded) - you will find the code in Catalog/templates/modules/product_info.tpl.php or if you have a modified template change the code in product_info.tpl.php in your modified templates/contents folder ============= --------------------------------------------------------------------------------------- <p><?php echo stripslashes($product_info['products_description']); ?></p> <?php $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); --------------------------------------------------------------------------------------- and add this just *before* it: --------------------------------------------------------------------------------------- <?php // start Get 1 Free // If this product qualifies for free product(s) display promotional text $get_1_free_query = tep_db_query("select pd.products_name, g1f.products_free_quantity, g1f.products_qualify_quantity 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 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); echo '<p class=get1free>' . 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>'; } // end Get 1 Free ?> --------------------------------------------------------------------------------------- This will display the promotional text on the top of the Products page, between the product name and the description text. This block of code can be placed elsewhere on the page if you wish. See the use.txt file for hints on customizing this text. Don't forget to save that file and close it. If you want to change the way the promotional text looks, add the following to your stylesheet.css: --------------------------------------------------------------------------------------- .get1free { font-family: Verdana, Arial, sans-serif; font-size: 10px; background: #ffb3b5; font-weight: bold;} --------------------------------------------------------------------------------------- Change the values in that style in any way that pleases you. Now save that file and close it. Now open catalog/shopping_cart.php and find the following code [around line 145]: ============== (CRE Loaded) - you will find the code in Catalog/templates/modules/shopping_cart.tpl.php ============== --------------------------------------------------------------------------------------- $info_box_contents[$cur_row][] = array('align' => 'center', 'params' => 'class="productListing-data" valign="top"', 'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id'])); --------------------------------------------------------------------------------------- and change that last line to: --------------------------------------------------------------------------------------- 'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']). tep_draw_hidden_field('free[]', $products[$i]['free']) ); --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/includes/application_top.php and find the following code [around line 351]: --------------------------------------------------------------------------------------- } else { $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : ''; } $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); --------------------------------------------------------------------------------------- and replace that last line with: --------------------------------------------------------------------------------------- // Start get 1 free if ($HTTP_POST_VARS['free'][$i] != 1) { $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); } // End get 1 free --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/includes/database_tables.php and find the following code [around line 29]: --------------------------------------------------------------------------------------- define('TABLE_CUSTOMERS_INFO', 'customers_info'); --------------------------------------------------------------------------------------- and add this just after it: --------------------------------------------------------------------------------------- // Get 1 Free define('TABLE_GET_1_FREE', 'get_1_free'); --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/includes/classes/shopping_cart.php and find the following code [starting around line 157]: --------------------------------------------------------------------------------------- function count_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)) { $total_items += $this->get_quantity($products_id); --------------------------------------------------------------------------------------- and add the following just after it: --------------------------------------------------------------------------------------- // start Get 1 free // If this product qualifies for free product(s) add in the number of free products if (is_array ($free_product = $this->get1free ($products_id))) { $total_items += $free_product['quantity']; } // end Get 1 free --------------------------------------------------------------------------------------- Now find the following code [starting around line 191]: --------------------------------------------------------------------------------------- function remove($products_id) { global $customer_id; unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } --------------------------------------------------------------------------------------- and add the following just after it: --------------------------------------------------------------------------------------- // start Get 1 Free // If this product qualifies for free product(s) remove the free products if (is_array ($free_product = $this->get1free ($products_id))) { $pid = (int)$free_product['id']; print '<br>Found Product: ' . $pid; unset($this->contents[$pid]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($pid) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($pid) . "'"); } } // end Get 1 Free --------------------------------------------------------------------------------------- Now find the following code [starting around line 259]: --------------------------------------------------------------------------------------- $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); --------------------------------------------------------------------------------------- and add the following just after it: --------------------------------------------------------------------------------------- // start Get 1 Free // If this product qualifies for free product(s) add in the total weight of free products if (is_array ($free_product = $this->get1free ($products_id))) { $this->weight += $free_product['quantity'] * $free_product['weight']; } // end Get 1 Free --------------------------------------------------------------------------------------- Now find the following code [starting around line 324]: --------------------------------------------------------------------------------------- $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); --------------------------------------------------------------------------------------- and add the following just after it: --------------------------------------------------------------------------------------- // start Get 1 free if (is_array ($free_product = $this->get1free ($products_id))) { // Add the free product to the shopping cart (Customer cannot alter this) $products_array[] = array('id' => $free_product['id'], 'name' => $free_product['name'], 'model' => $free_product['model'], 'image' => $free_product['image'], 'price' => 0, 'quantity' => $free_product['quantity'], 'weight' => $free_product['weight'], 'final_price' => 0, 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => '' ); } //if (is_array // end Get 1 free --------------------------------------------------------------------------------------- Now save that file and close it. Now find the following code [around line 346]: --------------------------------------------------------------------------------------- $products_array[] = array('id' => $free_product['id'], 'name' => $free_product['name'], 'model' => $free_product['model'], 'image' => $free_product['image'], 'price' => 0, 'quantity' => $free_product['quantity'], 'weight' => $free_product['weight'], 'final_price' => 0, 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => '' --------------------------------------------------------------------------------------- and change the last line of that to: --------------------------------------------------------------------------------------- 'attributes' => '', 'free' => 1 --------------------------------------------------------------------------------------- Now find the following code [starting around line 430]: --------------------------------------------------------------------------------------- function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } --------------------------------------------------------------------------------------- and add the following just after it: --------------------------------------------------------------------------------------- // start Get 1 Free function get1free ($products_id) { global $languages_id; $get_1_free_query = tep_db_query("select products_free_id, products_free_quantity, products_qualify_quantity, products_multiple, get_1_free_expires_date from " . TABLE_GET_1_FREE . " where products_id = '" . (int)$products_id . "' and status = '1'" ); if (tep_db_num_rows($get_1_free_query) > 0) { $get_1_free = tep_db_fetch_array($get_1_free_query); //Check that the offer has not expired //MNK bugfix 13.08.2007 if (($get_1_free['get_1_free_expires_date'] <= date('Y-m-d H:i:s')) && ($get_1_free['get_1_free_expires_date'] != '0000-00-00 00:00:00')) { //offer has expired, so update the database and return false tep_db_query("update " . TABLE_GET_1_FREE . " set status = '0', date_status_change = now() where products_id = '" . (int)$products_id . "'" ); return false; } else { // Offer is valid, so check if the quantity qualifies $products_quantity = $this->contents[$products_id]['qty']; if ($products_quantity >= $get_1_free['products_qualify_quantity']) { // Qualifies, so get the quantity of free products $free_quantity = 1; if ($get_1_free['products_multiple'] > 1) { $free_quantity = floor ($products_quantity / $get_1_free['products_qualify_quantity']); if ($free_quantity > $get_1_free['products_multiple']) { $free_quantity = $get_1_free['products_multiple']; } } // Get the info on the free product $products_free_query = tep_db_query("select pd.products_name, p.products_model, p.products_image, p.products_weight from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$get_1_free['products_free_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'" ); $products_free = tep_db_fetch_array($products_free_query); // Return an array of free product values $output = array ( 'id' => $get_1_free['products_free_id'], 'quantity' => $free_quantity, 'name' => $products_free['products_name'], 'model' => $products_free['products_model'], 'image' => $products_free['products_image'], 'weight' => $products_free['products_weight'] ); return $output; } //if ($products_quantity } //else }//if (tep_db_num_rows // offer was not valid (disabled or expired) return false; }//function // end Get 1 Free --------------------------------------------------------------------------------------- Now save that file and close it. Now open catalog/includes/languages/english/product_info.php and find the following code [around line 20]: --------------------------------------------------------------------------------------- define('TEXT_CLICK_TO_ENLARGE', 'Click to enlarge'); --------------------------------------------------------------------------------------- and add this just after it: --------------------------------------------------------------------------------------- // Get 1 Free define('TEXT_GET_1_FREE_PROMOTION', '<b>Special limited offer: Buy %u %s and get %u %s free!</b>'); --------------------------------------------------------------------------------------- This text may be modified to suit your needs -- see the use.txt file for hints. Now save that file and close it. That's it for the modifications. You can now go read use.txt to learn how to set up a promotion. ======== Support: ======== Please post any questions on the Contributions Support Forum. http://www.oscommerce.com/forums/index.php?showtopic=255288 Quote Link to comment Share on other sites More sharing options...
Adam46 Posted February 18, 2008 Share Posted February 18, 2008 I have just installed this addon It is just what I wanted. Made a few minor tweeks to it so that is show the product if a free gift at all stages of the order process. Thanks again for the clear and easy to understand instructions. Much appreciated :) :thumbsup: Quote Link to comment Share on other sites More sharing options...
macmizer Posted February 18, 2008 Share Posted February 18, 2008 I have added this contribution and it seemed to be working fine at first. For example, we setup all 5 products we have in the catalog to offer buy 2 and get 1 of the same product free. If I go to any one of the products and say Buy Now it will allow me to change the quantity from 1 to 2 and then I will see two different items in my cart. One will show the two products I am buying as well as the total price for both and then it will show a 2nd pic of the same product I ordered 2 of. This time on the 2nd item it will show quantity of "1" and no cost. This is all well and good. But here is the problem, all of the products we sell have an attribute for the different flavors we sell. So for one product I may have three different flavors. If I order one chocolate and one vanilla, the buy 2 get one free does not work any longer. I can order one chocolate and then one vanilla and then add one chocolate again for a total of 2 chocolates. Then I have three line items in my cart, the one vanilla with a price next to it, 2 chocolates with the total of both items then a third line item that shows a price of $0.00. Now the first two line items have the name of the flavor right below the product name but for the freebie item it never shows the flavor the person is getting which in my test case would be chocolate. Is there some kind of workaround for this? Since the admin piece does not give me control over the attributes of the product I don't see a way around this. So if I have 3 to 5 flavors of a product I will have to create 3 or 5 seperate products all with identical info and just change the name of the product to include the flavor. Not an option we want to do. So to recap there are two issues, teh free product does not show the attribute of the product that is included free and when buying two of one item if there is an attribute involved it will not work either. Anyone have any ideas? I have just installed this addon It is just what I wanted. Made a few minor tweeks to it so that is show the product if a free gift at all stages of the order process. Thanks again for the clear and easy to understand instructions. Much appreciated :) :thumbsup: Quote Link to comment Share on other sites More sharing options...
♥kymation Posted February 19, 2008 Author Share Posted February 19, 2008 This contribution does not currently handle attributes at all. It would be tricky to add and I just haven't had the time to work on it. I'm not even convinced that it can be done, since there is no obvious way for the customer to choose the attributes of the free product. The workaround is to create a separate set of products, in a hidden category, that have no attributes. These are then used as your free products. I agree that this is clumsy, and I understand why you don't want to do this. Perhaps you could just display a note at the bottom of the cart, telling the customer to state the flavor they prefer in the Comments box. That's the best I can think of right now. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Adam46 Posted February 21, 2008 Share Posted February 21, 2008 Just uploaded a new version of this (1.4) which now removes the "Get 1 Free" hen the expire dte has passed. The prevoius version only did this after you went through the check out process. New Version Quote Link to comment Share on other sites More sharing options...
tanicos Posted February 22, 2008 Share Posted February 22, 2008 Just uploaded a new version of this (1.4) which now removes the "Get 1 Free" hen the expire dte has passed. The prevoius version only did this after you went through the check out process. New Version i've got a lot of errors using this latest version. 1.Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ......includes/functions/database.php on line 103 This stays on my header all the time 2. in checkout_shipping.php Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in..../includes/functions/database.php on line 103 Warning: Cannot modify header information - headers already sent by (output started at ..../includes/functions/database.php:103) in...includes/functions/general.php on line 33 thanks in advance Quote Web 2.0 Button Images Link to comment Share on other sites More sharing options...
carolannjo Posted February 26, 2008 Share Posted February 26, 2008 I am also getting the error message: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/creative/public_html/includes/functions/database.php on line 103. I have installed Get 1 free 1.4 and I also installed Category Discount module today. I can't find a problem in either installation, but it appears to be something to do with Get 1 Free. Any solution for this yet? I am using osc 2.2 (not RC1). Thanks, Carol Ann Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.