Roaddoctor Posted February 1, 2015 Share Posted February 1, 2015 not a bug really, but noticed all products show up in the free product dropdown list regardless of status in the shop. So I added: and p.products_status = '1' // Remember selected free product in the dropdown $free_products = array(); $free_array = array(); $free_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 . "' and p.products_status = '1' order by products_name"); while ($free = tep_db_fetch_array($free_query)) { $free_products[] = array('id' => $free['products_id'], 'text' => $free['products_name'] . ' (' . $currencies->format($free['products_price']) . ')'); $free_array[$free['products_id']] = $free['products_name']; } // End remember Quote -Dave Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 1, 2015 Share Posted February 1, 2015 @@Roaddoctor Great idea! I haven't tested it yet but we could add the same status check inside the query on line 161? For the promotion product. Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 (edited) @@Roaddoctor just tested your query works like a charm! But my suggestion to add the same status in the query on line 161/162 doesn't work. So i looked for this function inside the admin/includes/functions/general.php function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') { and there is a $products_query. Inside that query i added and p.products_status = '1' and it works. Now the "promoted" products dropdown and the "free" products dropdown won't list up products that have a products_status = 0. Cool! I guess i'll need to add this to the install manual. And I hope that this is the last change/fix for this addon. I will rewrite the manual and update all necessary files and upload it with a new version number to the addons area. Thanks again for all the help. Appreciated! :thumbsup: Edited February 2, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
Roaddoctor Posted February 2, 2015 Share Posted February 2, 2015 yep I think your gold. Only other tweaks I've made was changing the product_info.php line from a <p> to <div>, moved the <div> to above the <PiGal> section, and applied this css .get1free { font-family: Verdana, Arial, sans-serif; font-size: 11px; background: #F9F9F9; font-weight: bold; overflow: hidden; margin: 1em; padding: 1em 1em 1em 2em; border-left: 4px solid #090; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.125); } I'm quite happy. Here is a example of the result. Thanks for the efforts! @@Tsimi Quote -Dave Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 @@Roaddoctor Oh that looks nice Dave. And you customized it to show the expire date. Where the message should appear is a design layout thing. But it looks way better than the simple red background. If you don't mind i would like to use your css for the install manual. If that's OK with you. And i will add the expire date thing inside the message like you have if expire date is set. Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 (edited) How about this inside the product_info.php <?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, 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 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 '<div class=get1free><strong>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], $free_product['products_name']) . '</strong>'; if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) { echo '<i>' . TEXT_OFFER_ENDS . ' ' . tep_date_long($free_product['get_1_free_expires_date']) . '</i>'; } echo '</div>'; } // end Get 1 Free ?> and add new language define inside the /languages/english/product_info.php define('TEXT_OFFER_ENDS', ' - Limited time offer ends'); Edited February 2, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 (edited) @@Roaddoctor In your case you might consider to add a <br /> tag after the first bold text so that - Limited time offer ends Saturday 28 February, 2015 it breaks down to the next line. Edited February 2, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
Roaddoctor Posted February 2, 2015 Share Posted February 2, 2015 @@Tsimi Since the css already has the font weight at bold, I changed slightly your code... just cosmetic stuff here. <?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, 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 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 '<div 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']); if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) { echo '<span style="font-weight:normal"><em>' . TEXT_OFFER_ENDS . ' ' . tep_date_long($free_product['get_1_free_expires_date']) . ' 11:59pm. </em></span>'; } echo '</div>'; } // end Get 1 Free ?> Very nice work... What do you think about hyperlinking the free item? good or bad idea? overlay layer? Quote -Dave Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 (edited) Thanks for fixing Dave! You mean something like in the package from 6 Jul 2008? Well that depends. My Free products is hidden and not showing inside the shop. This hiding function comes from my Master products addon. It doesn't deactivate the product but just hide it so linking to it makes no sense in my case but i think others would probably like the idea so yes sure why not. We could either add it to the code or we could add it as mod option inside the Get 1 Free Mods.txt file. Edited February 2, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 @@Roaddoctor Here is the code including hyperlink to the free product. The other question would be, open a new window (target="_blank") or redirect inside the same window? This code opens a new window to the free product. <?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_id, g1f.products_free_quantity, g1f.products_qualify_quantity, 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 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 '<div class=get1free>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_product['products_free_id']) . '" target="_blank">' . $free_product['products_name'] . '</a>'); if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) { echo '<span style="font-weight:normal"><em>' . TEXT_OFFER_ENDS . ' ' . tep_date_long($free_product['get_1_free_expires_date']) . ' 11:59pm. </em></span>'; } echo '</div>'; } // end Get 1 Free ?> I will probably add it like this and write something inside the Mods text file to remove target blank if they want to redirect inside the same window. Quote Link to comment Share on other sites More sharing options...
Roaddoctor Posted February 2, 2015 Share Posted February 2, 2015 Cool, I'll test that this evening, but then will be on the road for the next week. My initial thought was to do an image/caption using the photoset overlay. Keeping them on the product page they are interested in. @@Tsimi Quote -Dave Link to comment Share on other sites More sharing options...
♥Tsimi Posted February 2, 2015 Share Posted February 2, 2015 Get 1 Free v1.6 (normal osC 2.3.4) Get 1 Free v1.6BS (osC 2.3.4BS GOLD) uploaded to the addons area http://addons.oscommerce.com/info/4990 I think all known bugs are fixed now. Anything else from here on is just improvement to the code to make it better. Again thanks to @@Roaddoctor for help testing and improving. All credits to Jim for making this addon. Quote Link to comment Share on other sites More sharing options...
Roaddoctor Posted March 2, 2015 Share Posted March 2, 2015 (edited) @@Tsimi Bug I think - I had 8 specials running in Feb, all set to expire on 2/28/15 It's now 3/2/15, and it appears only the first item has switched status to off. The remaining 7 are still status active. also noticed this code has stopped working this quit working until I went back and updated all 8 entries with new expire date if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) { echo '<span style="font-weight:normal"><em>' . TEXT_OFFER_ENDS . ' ' . tep_date_long($free_product['get_1_free_expires_date']) . ' 11:59pm. </em></span>'; Edited March 2, 2015 by Roaddoctor Quote -Dave Link to comment Share on other sites More sharing options...
♥Tsimi Posted March 2, 2015 Share Posted March 2, 2015 @@Roaddoctor Hi Dave Yep, I had same issue here...had about 100 products set up with expire date Feb 28. Today March 2nd all were showing again. I will look into it.... Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted March 3, 2015 Share Posted March 3, 2015 (edited) OK did more testing... When i set up a product to expire date March 3rd (here in Japan is today) then the message shows for the first time and when adding that product to the cart the message disappears and also no free product is added to the cart. So it kinda works but the Special offer message stays until the moment I add the product to the cart. Edited March 3, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted March 3, 2015 Share Posted March 3, 2015 (edited) @@Roaddoctor I think I found the problem. EDIT: (2nd try, lol) I have this code inside the product_info.php (yours might look a bit different) <?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_id, g1f.products_free_quantity, g1f.products_qualify_quantity, 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 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 '<div class=get1free><strong>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_product['products_free_id']). '" target="_blank">' . $free_product['products_name'] . '</a>') . '</strong>'; if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) { echo '<em>' . TEXT_OFFER_ENDS . ' ' . tep_date_long($free_product['get_1_free_expires_date']) . '</em>'; } echo '</div>'; } // end Get 1 Free ?> as you can see there is a date checking (if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) {) but only for the last part of the message and not for the entire message. Make sense? So changing it to this should solve the issue. <?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_id, g1f.products_free_quantity, g1f.products_qualify_quantity, 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 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); if (($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) || ($free_product['status'] = 1)) { echo '<div class=get1free><strong>' . sprintf (TEXT_GET_1_FREE_PROMOTION, $free_product['products_qualify_quantity'], $product_info['products_name'], $free_product['products_free_quantity'], '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_product['products_free_id']). '" target="_blank">' . $free_product['products_name'] . '</a>') . '</strong>'; if ($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) { echo '<em>' . TEXT_OFFER_ENDS . ' ' . tep_date_long($free_product['get_1_free_expires_date']) . '</em>'; } echo '</div>'; } } // end Get 1 Free ?> Edited March 3, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted March 4, 2015 Share Posted March 4, 2015 That code above didn't work... <_< Set a product to March 4th yesterday, today message was still on. Adding the product in the cart doesn't add the free item so technically again OK. Somehow the status in the admin won't turn off when the date is reached. ...time for bug hunting... (w00t) Quote Link to comment Share on other sites More sharing options...
♥Tsimi Posted March 4, 2015 Share Posted March 4, 2015 (edited) found a small typo this if (($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) || ($free_product['status'] = 1)) { should be like this if (($free_product['get_1_free_expires_date'] > date('Y-m-d H:i:s')) || ($free_product['status'] == 1)) { forgot to add one additional = :blush: now it seems to work...when i set todays date even though the products status in the admin is not red the message doesn't show anymore which is good and no freebie item gets added to the cart. If i set a future date it shows the message and freebie item gets added to the cart. Just to make 100% sure before adding it as bug fix i setup few products in my test shop with tomorrows date. Let's see if that works this time... Edited March 4, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
Roaddoctor Posted March 4, 2015 Share Posted March 4, 2015 @@Tsimi wouldn't the source of the error be in the admin/get_1_free file? whereas the status does not flip to off/red dot at the expiration date just thinking out loud here Quote -Dave Link to comment Share on other sites More sharing options...
♥kymation Posted March 4, 2015 Author Share Posted March 4, 2015 The original code for this Addon was designed to check the expiration any time a page was loaded from the site and expire any offers that were past the end date. That code seems to have been lost somewhere in all of the updates. I suggest putting something like that back in. //// // Auto expire products on get_1_free function tep_expire_get_1_free() { $get_1_free_query = tep_db_query("select get_1_free_id from " . TABLE_GET_1_FREE . " where status = '1' and now() >= get_1_free_expires_date and get_1_free_expires_date > 0"); if (tep_db_num_rows($get_1_free_query)) { while ($get_1_free = tep_db_fetch_array($get_1_free_query)) { tep_set_get_1_free_status($get_1_free['get_1_free_id'], '0'); } } } 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...
♥Tsimi Posted March 4, 2015 Share Posted March 4, 2015 (edited) @@Roaddoctor hmmm...i looked at the get_1_free file and also compared it with the specials.php since they seem to be "similar" in the build up. Anyway, good timing it is 1 am (March 5th) here and that means that the products that i set yesterday (March 4th) are expired now. I went and looked at the products and....no message! and when I add the products to the cart no freebie gets added so the get 1 free function was never buggy just that message was not disappearing. The only bug i can see now is in the admin area that when the expire date is past the status light stays green until the product gets added at least once to the cart or gets deactivated manually. And even though the light is green no freebie gets added because the expire date is reached. The expire date stays in the admin area and setting the status to green with a past expire date does not show the message or doesn't add the freebie so again function works. @@kymation Thanks Jim! Do you remember around when that piece of code was removed from the get 1 free addon? Which version was the last that had that inside? Edited March 4, 2015 by Tsimi Quote Link to comment Share on other sites More sharing options...
♥kymation Posted March 4, 2015 Author Share Posted March 4, 2015 That code is in my copy of version 1.4.2, so it was sometime after that. I haven't checked all of the versions -- I'm a bit too busy right now for forensic archaeology. 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...
♥Tsimi Posted March 4, 2015 Share Posted March 4, 2015 @@kymation Thanks Jim. Time to do some digging. Quote Link to comment Share on other sites More sharing options...
Roaddoctor Posted March 18, 2015 Share Posted March 18, 2015 @@Tsimi This may only apply if you have Free Shipping per Product installed, not sure. /includes/classes/shopping_cart.php I changed // 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']; // charge shipping on free item breaks shipping quote if purchased item is free shipping $total_items += "0"; // free shipping on free item if purchased item is also free shipping } // end Get 1 free might not be the correct way to do it, but the result works so far. should it be? $total_items += "0" ; or $total_items += 0 ; Quote -Dave Link to comment Share on other sites More sharing options...
♥kymation Posted March 18, 2015 Author Share Posted March 18, 2015 All of those have the same result: they add zero to the existing total of $total_items. Which is to say they do nothing at all. If that's really what you want, it would be better to just comment out that line. 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...
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.