Jump to content
thejungle

Dangling Carrot (Free Gift/Discount Contrib)

Recommended Posts

Gift for new customer?

This contribution looks very cool.

 

I have the Credit Class Gift Voucher system installed, but I want to give away a free gift for new customers.

I haven't installed the Dangling Carrot yet.

 

Is it possible to set the carrot to only be availalbe once per customer or by entering a code from the New Account email message?

 

Is there another contribution that would be a better solution?


Sam M. - Seattle

Share this post


Link to post
Share on other sites
Gift for new customer?

This contribution looks very cool.

 

I have the Credit Class Gift Voucher system installed, but I want to give away a free gift for new customers.

I haven't installed the Dangling Carrot yet.

 

Is it possible to set the carrot to only be availalbe once per customer or by entering a code from the New Account email message?

 

Is there another contribution that would be a better solution?

 

I don't know if dangling carrot can do this or not so hopefully someone else will reply regarding it's functionality - but I do believe that Discount Coupon Codes could do this and I know that the creator of Discount Coupon Codes is in final testing of a new version that will have more features than the current release. It's contribution #4269 I believe.

 

As for the Dangling Carrot contrib. I'm still waiting to find out if it can handle what I need. I need a way to specify if any one of an array of products is in the cart, and also product ID 10 for example is in the cart, then Product ID 10 is free - otherwise Product ID 10 is $3.00 Basically, we have an information package that, when purchased by itself is $3.00, but when you purchase any of the products listed in the information package at the same time that you purchase the information package, then you get the information package for free. Can Dangling Carrot do this?


~Tracy
 

Share this post


Link to post
Share on other sites

Great contribution guys just one question??

 

How do I change the dollar sign to english???

 

Thanks :D

Share this post


Link to post
Share on other sites

I got the Dangling Carrots installed and working partially in CRE Loaded 6.2.08. It was a frustrating install since there is no clear direction on setting it up and using it. I think we can work to make it better as this is a very useful contrib. Like many others, I had the issue that the gift item was not being added to the cart once you click it. I found out by trial and error, that this problem happens when the free gift has been put on sale as well. Remove the sale price and it should work. Also don't forget to put a button_add_now.gif file to where the button images are called from in your package.

 

Being said that, I would like to be able to add a gift or special offer with a sale price once the threshold is reached. I am assuming a status has to be changed in the sale query but I have no clue how to do the mod. :blush: Any help will be highly appreciated.

 

Also, when you click the 'Product is Carrot' in the item description, that item is automatically made to hide from the catalog. This is intentional. I would like to make a page where I show the list of free or special offers with associated thresholds. I am assuming you can make duplicate entries of the carrots and hide their prices. But is there a better way? Any suggestions welcome.

Share this post


Link to post
Share on other sites

I have just completed installing this mod to our site and I noticed that the user is able to change the quantity of the FREE gift and receive more?(or think they will). Also what if you want the user to be able to choose between several gifts?

 

thanks for any help

 

P.S. - other than these two concerns this is a very great mod:)

Share this post


Link to post
Share on other sites
I am having a small problem with this contribution, i've installed it and i believe everything should be working fine, but when i try to go to the add_gift.php page i get this error;

 

1054 - Unknown column 'fg.products_id' in 'on clause'

SELECT fg.*, p.products_id, pd.products_name FROM free_gifts fg, products p LEFT JOIN products_description pd ON (pd.products_id=fg.products_id) WHERE pd.language_id = '1' AND p.products_id = fg.products_id ORDER BY fg.threshold ASC

[TEP STOP]

 

It seems like its a problem with my database or so, but i dont know what.. does anyone have an idea?

 

 

I saw a fix for the admin side but not the store side... I might have missed it but just in case, open shopping_cart.php and change

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM " . TABLE_CARROT . " fg, " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pd.products_id=fg.products_id)
WHERE pd.language_id = '".$languages_id."' AND p.products_id = fg.products_id AND p.products_status = '1' ORDER BY fg.threshold ASC");

 

to

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM (" . TABLE_CARROT . " fg, products p)
LEFT JOIN products_description pd ON (pd.products_id=fg.products_id)
WHERE pd.language_id = '".$languages_id."'
AND p.products_id = fg.products_id
ORDER BY fg.threshold ASC");


Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Share this post


Link to post
Share on other sites
for those who moved to mysql 5

 

edit your admin/gift_add.php

 

line 86

 

find this

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, pd.products_name FROM " . TABLE_CARROT . " fg, products p

LEFT JOIN products_description pd ON (pd.products_id=fg.products_id)

WHERE pd.language_id = '".$languages_id."'

AND p.products_id = fg.products_id

ORDER BY fg.threshold ASC");

 

and replace with this

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, pd.products_name FROM (" . TABLE_CARROT . " fg, products p)

LEFT JOIN products_description pd ON (pd.products_id=fg.products_id)

WHERE pd.language_id = '".$languages_id."'

AND p.products_id = fg.products_id

ORDER BY fg.threshold ASC");

 

Hi,

 

I was having the same problem when I went to gift_add.php in my admin. I fixed this by using the edit as above (thank you!).

 

However now I am also getting the below error message when I add an item to my cart or go to shopping_cart.php. I am also on mysql 5.

 

1054 - Unknown column 'fg.products_id' in 'on clause'

 

SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM free_gifts fg, products p LEFT JOIN products_description pd ON (pd.products_id=fg.products_id) WHERE pd.language_id = '1' AND p.products_id = fg.products_id AND p.products_status = '1' ORDER BY fg.threshold ASC

 

[TEP STOP]

 

Any clues anyone? Help would be greatly appreciated! I have spend hours on this and am still missing the solution...

 

Thanks,

Becdjane

Edited by beccajane

Share this post


Link to post
Share on other sites
Hi,

 

I was having the same problem when I went to gift_add.php in my admin. I fixed this by using the edit as above (thank you!).

 

However now I am also getting the below error message when I add an item to my cart or go to shopping_cart.php. I am also on mysql 5.

 

1054 - Unknown column 'fg.products_id' in 'on clause'

 

SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM free_gifts fg, products p LEFT JOIN products_description pd ON (pd.products_id=fg.products_id) WHERE pd.language_id = '1' AND p.products_id = fg.products_id AND p.products_status = '1' ORDER BY fg.threshold ASC

 

[TEP STOP]

 

Any clues anyone? Help would be greatly appreciated! I have spend hours on this and am still missing the solution...

 

Thanks,

Becdjane

 

 

Star - thank you Wendy James! Used your fix & it worked :)

Share this post


Link to post
Share on other sites

I am using v1.9 of dangling carrot in and moved to a server with mysql 5. (It is from a MS2-Max build from a few years ago) Now I'm getting that error:

 

1054 - Unknown column 'fg.products_id' in 'on clause'

 

SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM free_gifts fg, products p LEFT JOIN products_description pd ON (pd.products_id=fg.products_id) WHERE pd.language_id = '1' AND p.products_id = fg.products_id ORDER BY fg.threshold ASC

 

[TEP STOP]

 

I realize it's a mysql 5 error.

 

V1.9 doesn't have Carrot Table so I can't apply the code change Wendy suggests without an upgrade.

 

gift_add.php contains the following:

  $gift_list_query = tep_db_query("SELECT p.products_id, p.products_carrot, pd.products_id, pd.products_name FROM products p, products_description pd WHERE pd.language_id = '".$languages_id."'
		AND p.products_id = pd.products_id AND p.products_carrot = '1' ORDER BY pd.products_name ASC");
 while ($gift_list = tep_db_fetch_array($gift_list_query))
  $freeGifts[] = array('id' => $gift_list['products_name'], 'text' => $gift_list['products_name']);

 

shopping_cart contains the following:

		  $gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM free_gifts fg, products p
LEFT JOIN products_description pd ON (pd.products_id=fg.products_id)
  WHERE pd.language_id = '".$languages_id."' AND p.products_id = fg.products_id ORDER BY fg.threshold ASC");

 

Can anyone help me do one of 2 things - Either point me to an upgrade path to a version that works with Mysql 5+

or preferably - do you know what change to the code I should make to compensate.?

 

My shopping cart page does not come up at all right now when you add an item.

Share this post


Link to post
Share on other sites

If anyone else has this issue, here's the fix: Change catalog/shopping_cart.php

FROM:

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name FROM free_gifts fg, products p
LEFT JOIN products_description pd ON (pd.products_id=fg.products_id)
  WHERE pd.language_id = '".$languages_id."' AND p.products_id = fg.products_id ORDER BY fg.threshold ASC");

 

TO:

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_status, pd.products_name 
									  FROM (free_gifts fg, products p)
									LEFT JOIN products_description pd ON (pd.products_id=fg.products_id)
									  WHERE pd.language_id = '".$languages_id."' 
									  AND p.products_id = fg.products_id 
									  ORDER BY fg.threshold ASC");

Share this post


Link to post
Share on other sites
Actually - Is it a MYSQL 5 copmpatability issue?

 

There seem to be lots of MySQL 5 issues. Our server was upgraded yesterday, and I haven't stopped fixing things since! The patch from Sir Cuss fixed that problem, but I'm now finding I can't add freebies to the cart. I have had to change the way buy now links are made in the product_listing.php (in catalog/includes/modules/) - for some reason they work with the tep_draw_form function - and I think the dangling carrot issue is related.

 

For example, in product_listing.php the following code:

 

$lc_text = '<form name="buy_now_' . $listing['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now', 'NONSSL') . '"><input type="hidden" name="products_id" value="' . $listing['products_id'] . '" />' . tep_image_submit('button_buy_now.gif', TEXT_BUY . $listing_values['products_name'] . TEXT_NOW) . '</form> ';

 

had to be changed to:

 

$lc_text = tep_draw_form('buy_now' . $listing['products_id'], tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']), 'POST') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</form> ';

 

to get products to add to the basket from categories. (This also fixed the same problem with shop_by_price.php and product_reviews_info.php, incidentally).

 

So to get the freebies to add to the cart, I tried this in shopping_cart.php:

 

Replacing the code:

$freebie[$p]['link'] = '<form name="buy_now_' . $gift['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $gift['products_id']) . '"> <input type="hidden" name="products_id" value="' . $gift['products_id'] . '">' . tep_image_submit('button_add_now.gif', IMAGE_BUTTON_IN_CART) . ' </form>';

 

 

$freebie[$p]['link'] = tep_draw_form('buy_now' . $gift['products_id'], tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $gift['products_id']), 'POST') . tep_image_submit('button_add_now.gif', IMAGE_BUTTON_ADD_NOW) . '</form> ';

 

 

However, still no joy. Anyone got any ideas?

 

TIA,

Becca :'(

Share this post


Link to post
Share on other sites

Turned out that the problem was actually in includes/classes/shopping_cart.php:

 

// END Patch osc-060817
       $check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
       $check_product = tep_db_fetch_array($check_product_query);

       if (($check_product !== false) && ($check_product['products_status'] == '1')) {
         if ($notify == true) {
           $new_products_id_in_cart = $products_id;
           tep_session_register('new_products_id_in_cart');
         }

         if ($this->in_cart($products_id_string)) {
           $this->update_quantity($products_id_string, $qty, $attributes);
         } else {
           $this->contents[$products_id_string] = array('qty' => $qty);
// insert into database

 

See the link saying product_status == 1 ? Changed it to:

 

if (($check_product !== false) && ($check_product['products_status'] <= '1')) {

 

And I can now add the products (which are inactive) to the cart.

 

Hope it helps someone :-)

 

- Becca

Share this post


Link to post
Share on other sites
2) If you run a multi currency store it doesn't take into account additional currencies.

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

Share this post


Link to post
Share on other sites
Great contribution guys just one question??

 

How do I change the dollar sign to english???

 

Thanks :D

 

in the lanuage files and includes languages/english/product_info.php

Share this post


Link to post
Share on other sites

hi

 

just installed this on a test site that already has a load of other mods.

 

Couple of things

Found an error in the instructions in step 18 its missing a ; after the last )

 

I cant get step 21 to work (hiding the carrot from whats new)

I can understand the logic where p.products_carrot='0' but it still shows... think I have made a silly error but been through it a couple of times now.

 

any pointers would be much appreciated

Share this post


Link to post
Share on other sites

Hide carrots from whats new by editing catalog\includes\modules\new_products.php

 

and adding the products_carrot = '0'

right after the where of line 21 (start $new_products_query = tep_db_query("select p.products_id,..... )

 

this hides it from the what new box that appears in the main section of the index page

Share this post


Link to post
Share on other sites

Threshold can be set in catalog\shopping_cart.php

 

about line 51

 

if ( $deficit < 5 && $deficit > 0 )

 

 

where 5 is the threshold

(20 as standard)

Share this post


Link to post
Share on other sites

Hi, I've used this contribution and its gelled pretty well with my site,just one problem though,

When you go to the product_listing.php from the store, you see your carrot product on the list, and it also has a buy now button on it,which is definitely confusing for a customer, as this product wont be added to his cart being a carrot,can some1 plz help me with this ..?

 

Thank you in advance.

Share this post


Link to post
Share on other sites

Hi,

 

I have a question ragrding this Mod. What we want to do in our shop is to give a free gift if someone buy from a pool of products 4 pieces. So for exemaple I have Items x1, x2 ,x 3, x4, x5 and x6, A customer selects x1 , x3 x4, x6 in his basket then I want to give him free gift x7.

 

Can I use this mod for this purpose or do I need another MOD?

 

Thanks in advance,

 

 

Hans Koopman

Share this post


Link to post
Share on other sites

I'm sorry but I've made a mistake here.

 

What you have to replace in catalog/includes/languages/english/product_info.php is

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

Share this post


Link to post
Share on other sites

Hi,

 

I have installed the Dangling Carrot contribution and it works perfectly but I'd like to offer free shipping on it.

 

I'm charging a fixed price for the 1st item + fixed price per extra item so I'm not using the weight and I tried to install all the free shipping contributions and none are working with my set up (i.e. free shipping per item, per category, per zero weight, etc...).

 

For example, the customer has to buy 1 item to be entitled to the free product so I will charge him £1.50 postage for the item he's buying and with my actual setup he will also be charged £1 for the carrot. But this free carrot being worth less than £1, it doesn't seem fair to charge so much shipping for it and I think it might put customers off.

 

I'm not a coder and can't find a way around it...

 

Any help would be very much appreciated.

 

Florence

Edited by cleverflo

Share this post


Link to post
Share on other sites

Hi I just installed Dangling Carrot v2.6 on a heavily modded site and it is a great contribution! Exactly what my client wanted. I do have one question though. The instructions state:

 

If the cart value drops below the value for the gift (someone removes an item for example), the gift is automatically removed from the cart.

 

This part doesn't seem to work on my site and I was wondering if it works on others' carts or if I might have messed something up in the install? I've gone through my install instructions and don't see where I made an error, but I have so many other contributions on this site, that it could be bumping into one of them.

 

Thanks for a great contribution!

 

Janet

Edited by janetgot

Share this post


Link to post
Share on other sites
Hi I just installed Dangling Carrot v2.6 on a heavily modded site and it is a great contribution! Exactly what my client wanted. I do have one question though. The instructions state:

This part doesn't seem to work on my site and I was wondering if it works on others' carts or if I might have messed something up in the install? I've gone through my install instructions and don't see where I made an error, but I have so many other contributions on this site, that it could be bumping into one of them.

 

Thanks for a great contribution!

 

Janet

 

Hi Janet,

 

Was checking if I had a reply to my post and came across yours.

 

Just to let you know, it's working fine on my site. If I remove all items in the cart then the carrot disappears.

 

Florence

Share this post


Link to post
Share on other sites

Hi all

 

Thanks for this contrib and for all the feedback and extra help given on this thread - I was able to install the entire thing without any help from a programmer, thanks just to the instructions here. Our dangling carrot is working perfectly except for one small glitch - the carrot item doesn't show up on the invoice or packing slip. We need it to show up here as the orders are packed by a warehouse. Would anyone happen to have a fix for this problem? It would be greatly appreciated...

 

Cheers

OxfamIreland

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×