So I have just successfully installed this on a clean 1.3.8a. You CANNOT simply upload the files to your server, otherwise you will have problems that have already been described in this thread. The author has mixed 1.3.7 and 1.3.8 files in the latest release so you CANNOT upload the files as is.
What you need to do is compare the files that are overwritten. Merge ONLY those parts that have either carrot or gift in them, NOTHING ELSE!
You can upload the:
language files and extra_datafiles from both the admin and includes
the admin/includes/boxes
includes/modules/pages/shopping_cart
/main_template_vars.php
includes/modules/sideboxes/YOUR_TEMPLATE/gifts.php
and the buttons and sideboxes files in includes/templates/YOUR_TEMPLATE
since they do not overwrite anything. (if you already have tpl_shopping_cart in templates/YOUR_TEMPLATE/sideboxes then you will need to compare and merge it).
Here are the files to compare and merge:
admin/includes/functions/general.php
admin/includes/modules/category_product_listing.php
admin/includes/modules/copy_to_confirm.php
admin/includes/modules/update_product.php
admin/includes/modules/product/collect_info.php
includes/classes/shopping_cart.php
includes/functions/functions_categories.php
includes/index_filters/default_filter.php
includes/modules/pages/product_info/main_template_vars.php
includes/modules/pages/shopping_cart/header_php.php
The last step is to go to admin/gift_add.php and on line 107-108 delete this:
so that it will display the free gifts that you have already defined.PHP Code:pd.language_id = '".$languages_id."'
AND
I will eventually package this up properly so there are no more errors and post it in the downloads section, but until then - it might be a while since I am super busy - compare and merge and DO NOT upload the files from the compare and merge list above without first comparing and merging.
Questions? Ask away but please do not PM me because that will not benefit the entire community.
Alright, well it didn't take nearly as long to package up and upload, so it's done.As soon as it's approved it will be available from the downloads here:
http://www.zen-cart.com/index.php?ma...oducts_id=1145
This is for 1.3.8a, there should be no issues now but if you run into a problem please post it here.
I have just noticed that there is still broken functionality. When a free gift is in the cart and you change the cart value to fall below the threshold a fatal error is thrown. It has to do with the $cart->remove function call in includes/modules/pages/shopping_cart/main_template_vars.php on line 69. I am in the midst of figuring this out and will post the results soon(I hope!!) I really need to get this working so I will be devoting some time to it.
So for now, the latest release 1.3.3(whenever it is published in the downloads) is not ready for live carts.
OK! The error is fixed and the shopping cart is working properly now. It took me a little while to figure it out but I got there in the end and learned more about how zen cart works and PHP in general so it was a good learning lesson.
Anyway, the problem lies in includes/modules/pages/shopping_cart/main_template_vars.php
Right above:
addPHP Code:$num_in_cart = $_SESSION['cart']->show_total();
And then a little further down find:PHP Code:$cart = $_SESSION['cart'];
and add this right below:PHP Code:if ($products[$i]['id'] == $gift->fields['products_id']) { // gift already in cart
$gift_exists = $gift->fields['products_id'];
That's it! Now, when someone has a free gift already in the cart and they change the cart total so it falls below the threshold the gift will be automatically removed.PHP Code:$cart->remove($gift->fields['products_id']);
In this file you will see this line:
This is what defines when the dangling carrot message appears, you have to be within 20 of your currency for the carrot to dangle (it shows a message saying add x amount to your cart to receive this free gift). You can change 20 to whatever number you want, I have changed it to 60 so the carrot gets dangled sooner to inspire people to spend more.PHP Code:if ( $deficit < 20 && $deficit > 0 ) {
I am confident that this mod is 100% ready for production use, but would appreciate some testers putting it through it's paces to make sure there aren't any unforeseen bugs. I am going to upload the newest version now. PM me your email address and I can send it over sooner, I don't know how long it might take for my version to get put in the downloads.
I am working on some new features, too. I have created a new row in the free_gift table for a threshold_group, and have modified the admin/gift_add.php page to include adding this extra field. The goal is to use the threshold group to control what gifts are shown in the shopping cart page. I don't want people having to choose through gifts for the $100 range when they have already reached the $200 threshold, etc. Assigning each gift to a group will allow for logic to call only a certain group when a threshold has been reached. I should have this feature implemented very soon and will post the results.
Disregard this part of the modification. Do NOT insert the above line, it will not work right, but still do insert the first line in my last post. This is the correct modification in it's entirety again:
Still in includes/modules/pages/shopping_cart/main_template_vars.php, find this line:
and insert right above it:PHP Code:$num_in_cart = $_SESSION['cart']->show_total();
Go down the file and find this line:PHP Code:$cart = $_SESSION['cart'];
and insert this right after:PHP Code:else {
$near_limit = 0;
}
I have tested and retested and retested and it works as expected. If the cart value changes and falls below the threshold and a free gift is in the cart it will automatically be removed.PHP Code:if ($products[$i]['id'] == $gift->fields['products_id'] && $num_in_cart < $gift->fields['threshold']){ $cart->remove($gift->fields['products_id']); zen_redirect(zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL')); }
The only issue that I can see right now is if a coupon or order total discount such as quantity discount is used during checkout and that brings the cart down below the threshold, the gift will not be removed. I am going to check into that to see what I need to do to change it. If anyone wants to chip in an opinion on how to do it, I am all ears!![]()
This bit is needed if your site has more than one language, otherwise the gift products shown on http://yoursite/admin/gift_add.php are repeated for each language.
Last edited by paul3648; 27 Aug 2009 at 08:54 PM. Reason: clarify
Ah, ok. I only use one language so that never came up and that fix worked for me. Does the page display correctly if you don't delete the line? The existing gifts should be displayed above the field for inserting a new gift, and should show the threshold, product name, and edit and delete buttons. It wasn't showing until I made that edit, so this is obviously not the way to go about it and I will look at the code more closely to see what the correct fix will be.
Thanks for bringing it to my attention.
Yes, the display is correct with those original lines.
I've just installed this on my test site by using the compare and merge method, as well as modifying the main_template_vars.php as per your instructions to delete the gift when the cart contents fall below the threshold. If the gift item has attributes, errors are thrown up, so it's best just to remove any attributes from gift items. Otherwise it seems to work well.