Page 8 of 24 FirstFirst ... 67891018 ... LastLast
Results 71 to 80 of 237
  1. #71
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    Fixed the sidebox not working, this is for 1.3.7.1.

    In includes/templates/YOUR_TEMPLATE/sideboxes/tpl_gifts.php on line 35 replace:

    PHP Code:
    $info_box_contents = array(); 
    with

    PHP Code:
      $row 0;
      
    $col 0;
      
    $list_box_contents ''
    That fixes non-gift products from showing in the sidebox. Now everything is working 100%, just need some formatting/css styling to all of the parts of this mod and I will be adding it to the live site.

    Zen Cart and it's community are the best!!

  2. #72
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    Quote Originally Posted by gbnet View Post
    I'm using zencart version 1.3.8a and in the admin the items that I added as free gifts did not appear under the Free Gifts heading. I removed this sql bit "pd.language_id = '".$languages_id."'
    AND" from lines 107-108 in admin/gift_add.php and it worked. It was coming up with pd.language_id = '' and no results were being returned.
    Thanks for that, I was wondering what was going on! I will add this fix to the next release, I am going to go ahead and package up my changes to update the release in the downloads. I need to try this on a clean 1.3.8a install to see if there are any other bugs first.

    Zen Cart and it's community are the best!!

  3. #73
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    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:
    PHP Code:
    pd.language_id '".$languages_id."'
     
    AND 
    so that it will display the free gifts that you have already defined.

    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.

    Zen Cart and it's community are the best!!

  4. #74
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    Quote Originally Posted by lankeeyankee View Post
    I will eventually package this up properly so there are no more errors and post it in the downloads section
    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.

    Zen Cart and it's community are the best!!

  5. #75
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    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.

    Zen Cart and it's community are the best!!

  6. #76
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    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:

    PHP Code:
    $num_in_cart $_SESSION['cart']->show_total(); 
    add

    PHP Code:
    $cart $_SESSION['cart']; 
    And then a little further down find:

    PHP Code:
    if ($products[$i]['id'] == $gift->fields['products_id']) { // gift already in cart
     
    $gift_exists $gift->fields['products_id']; 
    and add this right below:

    PHP Code:
    $cart->remove($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.

    In this file you will see this line:

    PHP Code:
    if ( $deficit 20 && $deficit ) { 
    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.

    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.

    Zen Cart and it's community are the best!!

  7. #77
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    Quote Originally Posted by lankeeyankee View Post

    PHP Code:
    if ($products[$i]['id'] == $gift->fields['products_id']) { // gift already in cart
     
    $gift_exists $gift->fields['products_id']; 
    and add this right below:

    PHP Code:
    $cart->remove($gift->fields['products_id']); 
    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:

    PHP Code:
    $num_in_cart $_SESSION['cart']->show_total(); 
    and insert right above it:

    PHP Code:
    $cart $_SESSION['cart']; 
    Go down the file and find this line:

    PHP Code:
    else {
        
    $near_limit 0;
      } 
    and insert this right after:

    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')); } 
    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.

    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!

    Zen Cart and it's community are the best!!

  8. #78
    Join Date
    Mar 2007
    Location
    Taiwan
    Posts
    241
    Plugin Contributions
    0

    Default Re: Free Gifts-Dangling Carrot support

    Quote Originally Posted by lankeeyankee View Post
    The last step is to go to admin/gift_add.php and on line 107-108 delete this:
    PHP Code:
    pd.language_id '".$languages_id."'
     
    AND 
    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

  9. #79
    Join Date
    Jan 2007
    Posts
    1,483
    Plugin Contributions
    10

    Default Re: Free Gifts-Dangling Carrot support

    Quote Originally Posted by paul3648 View Post
    Just to be clear here, are you referring to these two lines?

    WHERE pd.language_id = '".$languages_id."'
    AND p.products_id = fg.products_id

    You can't delete these lines if your site has more than one language, otherwise the gift products shown on http://yoursite/admin/gift_add.php are repeated endlessly.
    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.

    Zen Cart and it's community are the best!!

  10. #80
    Join Date
    Mar 2007
    Location
    Taiwan
    Posts
    241
    Plugin Contributions
    0

    Default Re: Free Gifts-Dangling Carrot support

    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.

 

 
Page 8 of 24 FirstFirst ... 67891018 ... LastLast

Similar Threads

  1. Free Gifts - Dangling Carrot installation question
    By simpledomaining in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 26 Oct 2011, 03:27 PM
  2. Dangling carrot
    By strelitzia in forum All Other Contributions/Addons
    Replies: 13
    Last Post: 8 Dec 2009, 10:43 PM
  3. Dangling Carrot - lost my admin
    By tonyb in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 5 Nov 2008, 11:19 PM
  4. Dangling Carrot Mod
    By strelitzia in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 5 Oct 2008, 11:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg