Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Dangling Carrot (Free Gift/Discount Contrib)


thejungle

Recommended Posts

I can't find it now... either remember it

 

but knowing mistakes compare two version with "beyond compare" or similiar... and when you watch something diferent about languages... there is the bug

 

If you cant find it so i will try it another time

 

 

Hi David

 

Unfortunately i tried to replace those language definitions but without luck. :( Please Help :)

 

Greetings :)

Link to comment
Share on other sites

  • Replies 308
  • Created
  • Last Reply

Top Posters In This Topic

I was saying this...

 

catalog/includes/languages/english/product_info.php

ADD before the closing ?>

define('TEXT_FREE_GIFT', 'Free gift with $' . $product_gift['threshold'] . ' purchase.');
define('TEXT_DISCOUNT_GIFT', 'Only ' . $currencies->display_price($gift['products_price'], tep_get_tax_rate($gift['products_tax_class_id'])) . ' with $' . $product_gift['threshold'] . ' purchase.');

 

suerte!

Link to comment
Share on other sites

Hi David

 

Unfortunately i tried to replace those language definitions but without luck. :( Please Help :)

 

Greetings :)

 

 

I took a look a the last version and it's a simple matter of the omitted parts in the query.

 

In your shopping cart look for the query that begins like this:

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image,

 

Then add "

p.products_tax_class_id,

"

 

Next look for this line:

 

if ($gift['products_id'] != $gift_exists && $deficit <= 0) { // this particular gift is not in cart but qualifies

 

and change the line after that to this:

 

$freebie[$p]['message'] .= sprintf(TEXT_QUALIFIED_FOR_GIFT, $currencies->display_price($gift['threshold'],tep_get_tax_rate($gift['products_tax_class_id'])));

 

 

The change above will populate the line as it should when they've spend enough money for a gift e.g. "By spending over $100.00 you have qualified for the following gift! "

 

You'll have to make one more change to show folks how much they have yet to spend to get the gift:

 

Look for the line:

 

if ($gift['products_id'] != $gift_exists) { // this particular gift is not in cart

 

and change the line below it to:

 

$freebie[$p]['message'] .= sprintf(TEXT_CLOSE_TO_FREE_GIFT, $currencies->display_price($deficit,tep_get_tax_rate($gift['products_tax_class_id'])));

 

Sorry, I don't have line numbers to reference for you as my shopping cart page is almost completely rewritten, however, the above references should be good enough.

Edited by foodawgmi
Link to comment
Share on other sites

I took a look a the last version and it's a simple matter of the omitted parts in the query.

 

In your shopping cart look for the query that begins like this:

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image,

 

Then add "

p.products_tax_class_id,

"

 

Next look for this line:

 

if ($gift['products_id'] != $gift_exists && $deficit <= 0) { // this particular gift is not in cart but qualifies

 

and change the line after that to this:

 

$freebie[$p]['message'] .= sprintf(TEXT_QUALIFIED_FOR_GIFT, $currencies->display_price($gift['threshold'],tep_get_tax_rate($gift['products_tax_class_id'])));

 

 

The change above will populate the line as it should when they've spend enough money for a gift e.g. "By spending over $100.00 you have qualified for the following gift! "

 

You'll have to make one more change to show folks how much they have yet to spend to get the gift:

 

Look for the line:

 

if ($gift['products_id'] != $gift_exists) { // this particular gift is not in cart

 

and change the line below it to:

 

$freebie[$p]['message'] .= sprintf(TEXT_CLOSE_TO_FREE_GIFT, $currencies->display_price($deficit,tep_get_tax_rate($gift['products_tax_class_id'])));

 

Sorry, I don't have line numbers to reference for you as my shopping cart page is almost completely rewritten, however, the above references should be good enough.

 

 

Hello i applied your changes and it works!! Really great Support!!!

 

Just a little qustion: I have set a free gift with a Threshold of 100$. i have a shopping cart value of 86.95 and the free gift is showing up. The displayed amount that is missing though is not correct. i get displayed: Spend just 14.04 CHF more to get ..

 

so instead of having 13.05 (maybe it takes 101 )

 

if the shopping cart value reaches 94.90 then i get Spend just 5.49 CHF more to get

 

Any idea? our shop has prices with taxes and 2 currencies

Link to comment
Share on other sites

Hello i applied your changes and it works!! Really great Support!!!

 

Just a little qustion: I have set a free gift with a Threshold of 100$. i have a shopping cart value of 86.95 and the free gift is showing up. The displayed amount that is missing though is not correct. i get displayed: Spend just 14.04 CHF more to get ..

 

so instead of having 13.05 (maybe it takes 101 )

 

if the shopping cart value reaches 94.90 then i get Spend just 5.49 CHF more to get

 

Any idea? our shop has prices with taxes and 2 currencies

 

I checked and i think the remaining amount as the tax included twice. For example threshold: 100, Shopping Cart Value is 98 difference would be 2. but its 2.15 displayed. Our tax is 7.6%. 2 + 7.6% = 2.15. so i think we need to leave out the tax in the line

$freebie[$p]['message'] .= sprintf(TEXT_CLOSE_TO_FREE_GIFT, $currencies->display_price($deficit,tep_get_tax_rate($gift['products_tax_class_id'])));

 

Thanks for your help.

 

greetings

Link to comment
Share on other sites

Hi,

I am getting this error when I go to "catagories" in my admin panel:

 

Parse error: parse error, unexpected T_STRING in /home/content/path/to/site/html/toybox/admin/includes/languages/english/categories.php on line 74

 

The code in my categories.php on line 74 is:

 

define('TEXT_PRODUCTS_DATE_AVAILABLE', 'Date Available:');

 

I removed the line above it which I added per the install instructions:

define('TEXT_CARROT_ISSET', 'This product is a Carrot.')

 

and that solved the problem. Does anyone know if this will affect how this contribution will work?

Link to comment
Share on other sites

I set up 2 different gifts, one set at $50 and the other at $150. When I had $45 worth of merchandise in my cart I was informed "Spend just $0.00 more to get ..." when in fact I had to spend $5 more. The item did not show up in the cart, but the average customer would think that they have already spent enogh for the free gift. Anyone know how to fix this glitch?

Link to comment
Share on other sites

OK, I found the fix in this thread, sorry for the double post. I now have another question. I want to set up my dangling carrot so that if a customer spends $50 they get one gift, but if they spend $150 they get another gift but not both gifts. Is this possible?

Edited by jester420247sl
Link to comment
Share on other sites

  • 2 weeks later...
I checked and i think the remaining amount as the tax included twice. For example threshold: 100, Shopping Cart Value is 98 difference would be 2. but its 2.15 displayed. Our tax is 7.6%. 2 + 7.6% = 2.15. so i think we need to leave out the tax in the line

$freebie[$p]['message'] .= sprintf(TEXT_CLOSE_TO_FREE_GIFT, $currencies->display_price($deficit,tep_get_tax_rate($gift['products_tax_class_id'])));

 

To be honest, I'm not too sure on how it works with the "show prices with taxes included" part of OSC and I'm also not sure what else was changed on your installation. If I set my shop to display prices with taxes, it still works as it was intended to; it shows taxes if someone's logged in and part of any of our zones where charge taxes, or no taxes if they are not.

Link to comment
Share on other sites

  • 1 month later...

I have installed this contribution and it is working fine apart from customers can change the quantity of the free gift in the shopping cart.

 

I know I must be missing something...but what ?

 

Can anyone help

 

Thanks

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

Hello,

 

the W3C says: Line 493, Column 714: cannot generate system identifier for general entity "action"

…ite-green-spot-p-8016.html?pid=5684&action=cust_order"></a></td> </tr><tr><t

 

For what is the action=cust_order&;pid=' . $gift_list ???

 

I have change it to action=cust_order&pid=' . $gift_list but the same Error.

 

Another Problem: the ALT-TAG in the Gifts Box is by my Website "150" by all Gifts? Any Ideas?

 

MfG

Andreas from Germany

Link to comment
Share on other sites

  • 2 weeks later...

I took a look a the last version and it's a simple matter of the omitted parts in the query.

 

In your shopping cart look for the query that begins like this:

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image,

 

Then add "

p.products_tax_class_id,

"

 

Next look for this line:

 

if ($gift['products_id'] != $gift_exists && $deficit <= 0) { // this particular gift is not in cart but qualifies

 

and change the line after that to this:

 

$freebie[$p]['message'] .= sprintf(TEXT_QUALIFIED_FOR_GIFT, $currencies->display_price($gift['threshold'],tep_get_tax_rate($gift['products_tax_class_id'])));

 

 

The change above will populate the line as it should when they've spend enough money for a gift e.g. "By spending over $100.00 you have qualified for the following gift! "

 

You'll have to make one more change to show folks how much they have yet to spend to get the gift:

 

Look for the line:

 

if ($gift['products_id'] != $gift_exists) { // this particular gift is not in cart

 

and change the line below it to:

 

$freebie[$p]['message'] .= sprintf(TEXT_CLOSE_TO_FREE_GIFT, $currencies->display_price($deficit,tep_get_tax_rate($gift['products_tax_class_id'])));

 

Sorry, I don't have line numbers to reference for you as my shopping cart page is almost completely rewritten, however, the above references should be good enough.

 

I just found this fix that you posted a while back... I was pulling my hair out with Dangling Carrot and this took care of my issues - any chance your fix will be included in the next release of the module? I'm sure others have had the same issues with "By spending over $0.00 you have qualified for the following gift!" not showing up properly as well as "Spend just $0.00 more to get..." not appearing correctly. You are a lifesaver!

Edited by moxie3
Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...

Hi,

 

Can I disable also purchased products only for gifts?

 

thanks!

 

 

Hello misantropo.

Yes you can.

 

It's just like it for any other module.

 

includes/modules/also_purchased_products.php

Just before "products_status = '1'" add "p.products_carrot = '0'".

 

In my case I had:

 

   $orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED);

 

and now I have this:

   $orders_query = tep_db_query("select p.products_id, p.products_image from " . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p where opa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and opa.orders_id = opb.orders_id and opb.products_id != '" . (int)$HTTP_GET_VARS['products_id'] . "' and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_carrot = '0' and p.products_status = '1' group by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED);

 

______

 

Hola Misantropo... si que puedes yo lo acabo de hacer.

 

Supongo que a estas alturas ya lo tendrás resuelto pero si no arriba indico como tienes que hacerlo... espero que te sirva de ayuda.

 

Un saludo...

Edited by 2 estilos
Link to comment
Share on other sites

Hello everyone ... my English is very bad, I apologize. This is translated by google ... Sorry.

 

 

I have problems with the upgrade of the shopping cart with gifts.

I have installed the contribution so that the products are added automatically to the shopping cart to exceed the amount necessary (as indicated in the installation instructions). But I have problems ...

 

 

Give a gift when you make a purchase of 20 €, for example.

 

If you purchase an item of € 20, the gift item directly appears in the cart, as it should be ...

If I buy an article of 10 €, the gifts, as missing below € 10 in order to select the gift, Logic ...

BUT ...

If from the shopping cart quantity purchased is increased to 2 units for the 20 € of purchase, the product is automatically added as I wanted.

Not even I get the button to automatically add to the cart that gift (and still reported as missing € 10 to select the gift) TO GIVE YOU A SCREEN UPDATE.

 

I understand that this is the normal process of this contribution ... BUT ...

IF SOMEONE KNOWS HOW CAN I DO FOR THIS IS REALLY ALL AUTOMATIC, I will be very grateful ...

 

 

In advance ... THANK YOU FOR YOUR HELP

 

__________________

 

 

Hola a todos...

 

 

Doy un regalo cuando se realize una compra de 20€, por ejemplo.

 

Si se compra un articulo de 20€, el articulo de regalo aparece directamente en el carrito, como tiene que ser...

Si compro un articulo de 10€, el articulo de regalo, aparece abajo indicando que faltan 10€ para poder seleccionar el regalo, LOGICO...

PERO...

Si desde el carro de la compra se aumenta la cantidad comprada a 2 unidades, para obtener los 20€ de compra, el producto no se añade automáticamente como yo quisiera.

Ni tan siquiera me aparece de manera automática el botón de añadir a la cesta ese regalo (y sigue indicando que faltan 10€ para poder seleccionar el regalo) HASTA QUE LE DOY A ACTUALIZAR PANTALLA.

 

Entiendo que este es el proceso normal de esta contribución... PERO...

SI ALGUIEN SABE COMO PUEDO HACER PARA QUE TODO ESTO SEA REALMENTE AUTOMÁTICO, le estaré muy agradecido...

 

 

De antemano... MUCHAS GRACIAS POR VUESTRA AYUDA

Link to comment
Share on other sites

  • 4 weeks later...

Gday all! This looks great - but can anyone tell me if they have it working with no errors?

And does anyone know if it will work with the MRSP contrib that lists the RRP and the price and the savings > or will this make the Carrot contrib calculate incorrectly?

 

Thanks !

Edited by bonzabuy
Link to comment
Share on other sites

  • 2 months later...

Hi,

 

Hope all is excellent with y'all.

 

Two things I've encountered:

1. The carrot price is correct in shopping cart

but reverts to regular price during checkout,

anyone know what causes it/how to correct?

 

2. If a gift is in the cart,

another one can be added by adding a question mark to the URL:

http://www.MYSITE.com/shopping_cart.php?

and then finding the link in the link history dropdown or

simply typing it in:

eg. http://www.MYSITE.com/shopping_cart.php?action=buy_now&products_id=19

 

This increments the free gift by one each time the URL is navigated to.

 

Anyone know how to prevent this?

 

Thanks for any feedback.

 

jk

Edited by jfkafka
Link to comment
Share on other sites

  • 4 weeks later...

I took a look a the last version and it's a simple matter of the omitted parts in the query.

 

In your shopping cart look for the query that begins like this:

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image,

 

Then add "

p.products_tax_class_id,

"

 

Next look for this line:

 

if ($gift['products_id'] != $gift_exists && $deficit <= 0) { // this particular gift is not in cart but qualifies

 

and change the line after that to this:

 

$freebie[$p]['message'] .= sprintf(TEXT_QUALIFIED_FOR_GIFT, $currencies->display_price($gift['threshold'],tep_get_tax_rate($gift['products_tax_class_id'])));

 

 

The change above will populate the line as it should when they've spend enough money for a gift e.g. "By spending over $100.00 you have qualified for the following gift! "

 

You'll have to make one more change to show folks how much they have yet to spend to get the gift:

 

Look for the line:

 

if ($gift['products_id'] != $gift_exists) { // this particular gift is not in cart

 

and change the line below it to:

 

$freebie[$p]['message'] .= sprintf(TEXT_CLOSE_TO_FREE_GIFT, $currencies->display_price($deficit,tep_get_tax_rate($gift['products_tax_class_id'])));

 

Sorry, I don't have line numbers to reference for you as my shopping cart page is almost completely rewritten, however, the above references should be good enough.

 

That helped me a lot,

but a problem which left is something with the CLOSE_TO_FREE_GIFT Function,

Threshold value for a article is 100, the close to free gift funtion only shows up when i have an amount of ~70$ in my Cart ... 50$ and under nothing shows up ... is there a percentage connection or something?

Link to comment
Share on other sites

  • 4 months later...
  • 4 months later...

Thanks for this contribution!

I added the change to the inclusion of carrot automatically but I can not make a change.

If I have a list of 3 carrots into administration, the system puts all the carrots to the attainment of the quota.

 

I wish that in the cart should add only the carrot of the share reached

For example:

First carrot -> $ 50

According carrot -> $ 100

Third carrot -> $ 150

----------------------

 

if the value of the cart is $ 60 -> Automatic ONLY the first part of carrot (of course)

if the value of the cart is $ 115 -> Automatic ONLY the second part of carrot (remove the first one)

if the value of the cart is $ 200 -> Automatic ONLY part of the third carrot (remove the first and second)

 

I think it's a nice feature to apply to the contribution but I'm not so good :-)

Someone can help me?

 

thanks again

 

I am Italian ... thanks to google translator:-D

Edited by lp-studio
Link to comment
Share on other sites

  • 1 month later...

I was looking at the sql modifications and have doubts. It seems to be possible to filter on gifts without the additional column to products:

 

 

select count(distinct p.products_id) as total

from

products p

left join (specials s) on (p.products_id = s.products_id)

left join (products_description pd) on (p.products_id = pd.products_id and pd.language_id = '4')

<...>

left join (`free_gifts` f) on (p.products_id = f.products_id)

where

p.products_status = '1' and f.products_id IS NULL

 

Anyone thoughts on this?

 

Paul

Link to comment
Share on other sites

  • 2 months later...

Hi,

 

I hope you can help me. I want to combine this gift option with the discount code option. Both are now working seperately.

I only need to apply the gift option for 1 particular discount code. So I decided to hardcode this code into the shoppingcart. And that works with:

if ($num_in_cart >= $gift['threshold'] && $deficit <= 0 && strtoupper($sess_discount_code)=='xxxxx') {

...

} else if ($near_limit && strtoupper($sess_discount_code)=='xxxxx') {

....

if the customer goes in with a link with the discount code (i.e. shopdomain/?discount_code=xxxxx), it will work.

 

But normally the customer will enter the code on the checkout confirmation page. By that time, the shoppingcart content has not effect anymore on the order contents.

I don't mind it not showing up on the shoppingcart page (if the code is not know yet), but I would like to have the gift added and shown on the checkout confirmation page.

 

Any idea how to do that?

 

cheers...

Link to comment
Share on other sites

To continue my quest:

 

I tried adding the 'add-gift' code to the checkoutconfirmation page, which basically works, but it doesn't go straight to the payment page. it first returns to the checkout_shipping page, so 1 page back .

 

So I added the following code to the start of the checkout_confirmation page (I also tried to add to the checkout_payment page, but it has the same effect):

 

// test to add here: BOF //////////////////////// dangling carrot v2.0 //////////////////////////////////

 

if ($cart->count_contents() > 0 && strtoupper($sess_discount_code)=='xxxxx'){

// find any free gifts, and remove invalid ones

$num_in_cart = $cart->show_total();

$products = $cart->get_products();

 

$gift_query = tep_db_query("SELECT fg.*, p.products_id, p.products_model, p.products_price, p.products_image, p.products_tax_class_id, 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");

 

$threshold = 0;

$p=0;

$gift_price=0;

$gift_exists=0;

 

while ($gift = tep_db_fetch_array($gift_query)) { // loop through the current gifts

if ($gift_exists == 0){

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

if ($products[$i]['id'] == $gift['products_id']) { // gift already in cart

$gift_exists = $products[$i]['id'];

$gift_price = $gift['products_price'];

break;

}

}

}

 

 

if ($num_in_cart >= $gift['threshold']) {

// cart could qualify for this gift

// check to see if in cart already

// add to gift list if not in cart

if ($gift['products_id'] != $gift_exists ) { // this particular gift is not in cart but qualifies

if (!$cart->in_cart($gift['products_id'])) $cart->add_cart($gift['products_id']);

}

} else {

// cart cannot qualify for this gift

// remove if in cart

$cart->remove($gift['products_id']);

}

$threshold = $gift['threshold'];

}//while

}

 

//EOF dangling carrot v2.0

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...