Community Add-Ons
Dangling Carrot
for osCommerce Online Merchant v2.2
This allows you to create gifts (free or discounted) that appear at various levels of shopping cart value. See www.session1.com for an example of its use.
Added parenthesis in sql statements involving LEFT JOIN to solve incompatibilities with Mysql 5.0, which is more strict with respect to sql syntax rules. Only index.php and the Dangling Carrot instructions are changed from previous download. This is the full package.
For your gift not to show in your new product listing on your homepage go to Catalog/includes/modules/new_products.php and find
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
change this to
$new_products_query = tep_db_query("select p.products_carrot, p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_carrot = '0' and products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
I have included the new.products.php file
I'm very sorry but the previous fix was generating a "Warning: Missing argument 2 for display_price()" in product_info.php. Now it seems that the problem is solved.
define('TEXT_FREE_GIFT', 'Free gift with $' . $product_gift['threshold'] . ' purchase.');
With
define('TEXT_FREE_GIFT', 'Free gift with ' . $currencies->display_price($product_gift['threshold'], tep_get_tax_rate($product_gift['products_tax_class_id'])) . ' purchase.');
A member of oscommerce forums noticed that "If you run a multi currency store it doesn't take into account additional currencies." (http://forums.oscommerce.com/index.php?showtopic=139964 ).
To fix that go to catalog/includes/languages/english/product_info.php and Replace:
define('TEXT_FREE_GIFT', 'Free gift with $' . $product_gift['threshold'] . ' purchase.');
With
define('TEXT_FREE_GIFT', 'Free gift with ' . $currencies->display_price($product_gift['threshold']) . ' purchase.');
here is the CSS that was on the TODO LIST i includet German language files
Incorporated fix by safoo post #163 to fix a bug when an item was added after the gift was already in the cart and the qty was changed it changed the gift qty instead, now this is fixed.
UPGRADERS
Search & find:
'text' => $products[$i]['quantity']. tep_draw_hidden_field('products_id[]', $products[$i]['id']));
Replace With:
'text' => $products[$i]['quantity'] . tep_draw_hidden_field('cart_quantity[]', $products[$i]['quantity']) . tep_draw_hidden_field('products_id[]', $products[$i]['id']));
- Fixed two errors in instructions for new installers.
- Removed gift products from search results, new products page, and specials page (UPGRADERS do step 19-21).
- Optional auto add gift to cart code included.
FULL VERSION
Support thread: http://forums.oscommerce.com/index.php?showtopic=139964
- Added File and Language Variables (I think I got them all...)
- Added instructions for removing carrots from product listing and category counts
- Added configurable text in place of price on product info page for carrots.
eg. "Free with a $50 purchase"
or "Only $9.99 with a $30 purchase"
- Added instructions for the optional removal of the add to cart button on product_info.php for carrot items.
This fixed a bug I found that allowed a customer to add a carrot item to the cart even though the
threshold has not been met, if the price for the carrot item was greater than zero. But this created
another bug where a customer would not be able to add an item with attributes to their cart.
Maybe someone could add attributes boxes to the item list in shopping_cart.php? I tried, but...
TO DO:
- create classes in stylesheet for gift items table in shopping_cart.php
- add attribute boxes to gift items table in shopping_cart.php
- alter new_products to exclude carrot items and make exclusion configurable through admin
(sorry, I got tired - I'll get to it if no one else does...)
- make exclusion of carrot items in product_listing configurable through admin
- ?
Chris Tanner - AWESOME MOD! Kudos for starting something great!
----- Full Package with Modded files included -----
Now image will be shown
After installing version 2, the edit, update and delete functions are not working. HappyBear has provided a workaround code for this and I've updated the gift_add.php with the code by HappyBear to make it easier for others to use this great contribution. I claimed no credits as I simply zipped all the edited files by other coders and updated the package. As a newbie in this forum, I understand how confusing it is to search through lengthy posts and d/l numereous new fixed seperately. I'm not a coder nor I can help with any further problems you have, please refer to the contribution thread and posts your questions there.
= This is the full package =
Fixed errors in last update. This is a full version.
Removed the need to have the gift product name to start with Gift. The product is now marked in the database as a gift.
- Made image for displayed gifts a link to that products page
- Added code to ignore out of stock gift products
This is a full package.
Added an infobox to display the current gift items
When I changed the code two versions back, I introduced a new problem. The products could not be deleted with update. This is now fixed.
Fixed shopping_cart.php code to show a Add Now button
- Changed image display code to use alt text and database image size settings
- Added image size settings to admin
- Added drop down for gifts in admin
- Cleaned up form in admin
- Cleaned up instructions
4/2/05 Version 1.3
- fixed bug of gift not always being removed when other items removed.
- removed clickable links from shopping cart infobox
- now only 2 bug should be left: (1)if customer creates an account, shops around and saves a
shopping cart that includes a gift, logs out and then shops some items and adds a gift to cart. Then when he logs back in and the visitor and member cart merge, there will be 2 gifts in the cart. (2) Customer can click the 'select' button multiple times and multiple gifts will be added. Solution is same to resolve both these: Check that quantity is 1 for the gift. This version does not include this fix.
This is the complete package.
Support thread: http://forums.oscommerce.com/index.php?showtopic=139964
3/27/05 Version 1.2 update by Safoo
- this version assumes that gift products have product model set to "gift" (without quotes)
- the missing button from previous version is included
- quantity for gifts can not be changed after added to shopping cart. They can only be removed.
- The product link for gifts has been removed
- optimized the query (to best of my understanding :/) to help reduce overall queries and parse time in the shopping cart
Install file included. This is the complete package.
Any questions or comments, post at http://forums.oscommerce.com/index.php?showtopic=139964
All credits to Chris Tanner.
3/23/05 Version 1.1 update by Safoo
- Fixed some bugs in calculations of thresholds and issues when item quantity were removed from cart.
- Hopefully fixed the problem one person had of losing session.
The code is still not in correct OSC format with english files etc. Someone should do that next.
On my site, I create gifts with the model number as "gift". Then I edited the gift_add.php so that it only pulls the 'model == gift' products and not all products from the database.
I also did a change to the shopping_cart.php and removed the quantity and link from the cart so the quantity of the gift can not be changed to more than 1. Also the gift is no longer clickable.
These 2 changes are not included in this v1.1 package as I don't want to force everyone to do it my way.
If anyone is interested in this, post on the official thread at: http://forums.oscommerce.com/index.php?showtopic=139964
All credits to Chris Tanner.
It is recommended to test this on a non-live site first as everyone has slightly different stores.
Any problems, just post on the thread.
Admin German Language
Enter Domain in line 90 of the code please!
<a href="http://xxxxxxxx.de/admin/........
Backup Please
An update - that to delete should function now!
Enter Domain in line 90 of the code please!
<a href="http://xxxxxxxx.de/admin/........
An update - that to delete should function now!
This allows you to create gifts (free or discounted) that appear at various levels of shopping cart value. See www.session1.com for an example of its use.
