OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Tell customer how much more to spend to get free shipping
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Tips and Tricks
Pages: 1, 2
delaen
In includesboxesshopping_cart.php
REPLACE:
CODE
 if ($cart->count_contents() > 0) {

   $info_box_contents[] = array('text' => tep_draw_separator());

   $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()));

 }



WITH:

CODE
 if ($cart->count_contents() > 0) {

   $info_box_contents[] = array('text' => tep_draw_separator());

   $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()));

       

    if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {

 $add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();

     $info_box_contents[] = array('align' => 'right',

                                      'text' => sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping)));

 

    }

 }


In includeslanguagesenglish.php
ADD:
CODE
define('BOX_SHOPPING_CART_FREE_SHIPPING', 'Add %s to your order and receive FREE shipping!');


This will stick a message into your shopping cart box telling the customer how much more they need to add to their cart to qualify for free shipping.

I haven't tested this on anything that didn't have the "buy over a certain amount, get free shipping" option on, so be sure to test this first with your version.

To see a working copy, go to my site and add something to your cart. I didn't really think this qualified as a contribution, so I stuck it in this forum. Hopefully this isn't something that someone has done a long time ago and I just missed tongue.gif
Druide
very nice one, thanks for your effort
delaen
Instead of making you go through all that effort just to see what it looks like, I'll just post a picture tongue.gif

Mr. Ree
I would love to add this feature but I am a bit baffled.

In my catalogincludesboxesshopping_cart.php you say to look for;
CODE
 if ($cart->count_contents() > 0) {

   $info_box_contents[] = array('text' => tep_draw_separator());

   $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()));

 }


Mine looks like this;
CODE
if ($cart->count_contents() > 0) {

   $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';

   $products = $cart->get_products(); // $products[$i]['id'] .. $products[$i]['name'] .. $products[$i]['quantity']

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

     $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">';



     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {

       $cart_contents_string .= '<span class="newItemInCart">'; // highlight product quantity

     } else {

       $cart_contents_string .= '<span class="infoBoxContents">';

     }


This is from Ian's MS1 Loaded 5 with shopping_cart.php,v 1.1.1.1 2002/11/28 which looks a great deal like the current CVS.

What version boxes/shopping_cart.php are you using?

TIA
delaen
It should be further down the page. The current shopping_cart.php looks like this:

CODE
<?php

/*

 $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2003 osCommerce



 Released under the GNU General Public License

*/

?>

<!-- shopping_cart //-->

         <tr>

           <td>

<?php

 $info_box_contents = array();

 $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);



 new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART));



 $cart_contents_string = '';

 if ($cart->count_contents() > 0) {

   $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';

   $products = $cart->get_products();

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

     $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">';



     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {

       $cart_contents_string .= '<span class="newItemInCart">';

     } else {

       $cart_contents_string .= '<span class="infoBoxContents">';

     }



     $cart_contents_string .= $products[$i]['quantity'] . '&nbsp;x&nbsp;</span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';



     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {

       $cart_contents_string .= '<span class="newItemInCart">';

     } else {

       $cart_contents_string .= '<span class="infoBoxContents">';

     }



     $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>';



     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {

       tep_session_unregister('new_products_id_in_cart');

     }

   }

   $cart_contents_string .= '</table>';

 } else {

   $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;

 }



 $info_box_contents = array();

 $info_box_contents[] = array('text' => $cart_contents_string);



 if ($cart->count_contents() > 0) {

   $info_box_contents[] = array('text' => tep_draw_separator());

   $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()));

 }



 new infoBox($info_box_contents);

?>

           </td>

         </tr>

<!-- shopping_cart_eof //-->


The part that needs changed is:

CODE
 if ($cart->count_contents() > 0) {

   $info_box_contents[] = array('text' => tep_draw_separator());

   $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()));

 }


It should be around line 57.
hotnuts21
Great tip thanks smile.gif

Also great site too, very amazon -esk wink.gif
hotnuts21
he he he also just noticed this on your cart

QUOTE
Your shopping cart is empty. This is an indication that you are not buying enough.


LMAO laugh.gif

Sorry to go off topic :oops:
Mr. Ree
Too sweet!

Thanks Bob!
baresinsations
added this feature but it's calculating wrong. You must buy $100 or more for free ship. It's calculating it at $50
baresinsations
problem corrected, nice contrib. Thanks!
baresinsations
how did you get it to read Sub-total in the cart area?
delaen
QUOTE
problem corrected, nice contrib. Thanks!


Was it a problem with this code, or something else? Glad you got it working anyway.
baresinsations
problem was me smile.gif I didn't do something right. I started over and it worked. Thanks a bunch!
Oh and I found out how to do the sub-total thing as well:)
Thanks
Love your site
Stephan Gebbers
What do i have to add that it does show up only when free shipping is enabled in admin?

Regards,
Stephan Gebbers
Stephan Gebbers
hey, i did it this way now..

using MS1 loaded5
-setting the EUR or USD to 0.00 in Admin>Modules>Order-Total>Shipping will disable the display

CODE
if ($cart->show_total() > 0) {

if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {

     $add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();

         $info_box_contents[] = array('align' => 'right',

                                        'text' => sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping)));

  }

 }


L8er,
Stephan
delaen
QUOTE
hey, i did it this way now..

using MS1 loaded5  
-setting the EUR or USD to 0.00 in Admin>Modules>Order-Total>Shipping will disable the display

CODE
if ($cart->show_total() > 0) {

if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {

     $add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();

         $info_box_contents[] = array('align' => 'right',

                                        'text' => sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping)));

  }

 }


L8er,
Stephan


Yea, that should work for now. I'll see if I can find time to code it in a real way. I think it should only take about 2 seconds and 2 lines of code though.
penmarks
How can anyone do the following;I am not guru on this,please be gentle.
1In order to receive free shipment customer required to buy certain number of pieces of an item. e.g Buy 100 of an item and get free shipment
2)In order to receive free shipment customer required to buy certain number of pieces of an multible items.e.g.Buy total of 100 items and get free shipment.
Thanks in advance.
delaen
I'm not really sure. Sorry. sad.gif
gman
Great tip!

How do I get the "You are $X.XX away from FREE ground shipping" within the product_info page? and to work with an additional language as well?

I am testing a site with English and Spanish catalog content, and would need for message to change if customer selects Spanish or goes by default via browser to Spanish language version.

Hope you can help. For a view of test site : http://www.directmark.net/mp/dmp/product_i...434796192b928e9

Thanks.

Guillermo
delaen
QUOTE
Great tip!

How do I get the "You are $X.XX away from FREE ground shipping" within the product_info page? and to work with an additional language as well?


I don't use any other languages, but I assume you would just have to add
CODE
define('BOX_SHOPPING_CART_FREE_SHIPPING', 'Add %s to your order and receive FREE shipping!');
to that languages main page, and change the text to the right language.

About the other part: I haven't tested this in the least, but try adding

CODE
    if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {

 $add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();

 echo '<p>' . sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping));

    }


in product_info.php wherever you want to display the message. If that doesn't work at all...let me know.
gman
QUOTE
I don't use any other languages, but I assume you would just have to add  
CODE
define('BOX_SHOPPING_CART_FREE_SHIPPING', 'Add %s to your order and receive FREE shipping!');
to that languages main page, and change the text to the right language.

About the other part:  I haven't tested this in the least, but try adding  

CODE
    if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {

 $add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();

 echo '<p>' . sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping));

    }


in product_info.php wherever you want to display the message.  If that doesn't work at all...let me know.


Tried above code. Seems to work fine. Thanks for your help, Delaen.

Guillermo
KASR
works like a charm - you are da man!

KASR
alienated
i have attempted this and i get the same problem marie was getting where it calculates at $50 dollars instead of the $265.00 set in the shipping modules admin screen.

any suggestions?
baresinsations
look in admin>modules>order total>shipping and make sure you have that set at whatever you want. It defaulted back to $50 on me, that was where I was having my problem
chet
Has someone done the same with the quantity discount module ?

http://www.oscommerce.com/community/contributions,1159


I cannot find the module used with this free shipping hack
Horuss
Thank You! Thank You! Thank you!!!!!!
Works like a champ
haborsale
I put the code in the correct places I think, but I can't get it to work I am getting nothing to show up in the cart besides the item then when you go to check out you get an error.

Can someone please tell me what is wrong? I think this a great code and a great addition to our store.


Thank you
Horuss
Did you put your code in the shopping_cart.php file in Catalog>includes>languages>english?

I think that's the file I put it in
haborsale
I put the codes in the files that delaen stated in his post

This code in In includesboxesshopping_cart.php

if ($cart->count_contents() > 0) {
$info_box_contents[] = array('text' => tep_draw_separator());
$info_box_contents[] = array('align' => 'right',
'text' => $currencies->format($cart->show_total()));

if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
$add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();
$info_box_contents[] = array('align' => 'right',
'text' => sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping)));

}
}

This code in In includeslanguagesenglish.php

define('BOX_SHOPPING_CART_FREE_SHIPPING', 'Add %s to your order and receive FREE shipping!');

If this is not correct can you point me in the right direction, I would really like to put this into our store.

Thanks
haborsale
I got the free shipping info text to show up but when you go to add a second product to your shopping cart you get the following error

Warning: Cannot modify header information - headers already sent by (output started at /home/harbors/public_html/catalog/includes/languages/english.php:333) in /home/harbors/public_html/catalog/includes/functions/general.php on line 29


Does anyone have any idea what I am doing wrong?


Do you only put the codes in the following files

includesboxesshopping_cart.php

includeslanguagesenglish.php
Priest
Are you guys using 2.2MS2? Could this maybe be a problem with the new coding of MS2? If so, could someone update the HOWTO of this tip?

I have adde dit just fine to my snapshot of April, but have not yet added it to the new site I am puttign up with MS2. I want to make sure it will work.

Thanks,
Priest
delaen
I haven't tested it, but I don't imagine there being any problems. If anyone has any, please let me know.
Corwyn
Is there way to mod this so that it offer a different spending limit based on the category you're in and also a different one if it's a combonation?


Some thing like this ;

if customer buys from product cat A they have to spend X dollars to get free shipping.

If in cat b spend Y dollars,



Why? I have product lines that are on the average $70-120 dollars per item like telelphone headsets. I want to say to this customer that if they buy a top and an Amp they get free shipping.

On the other hand I also have phone systems that are in the $1500+ range. They weigh a lot and I can't assign the same level of discount for free shipping to these items as to the 2 pound/$200 headsets.

Corwyn
Corwyn
sorry
Corwyn
Is there way to mod this so that it offer a different spending limit based on the category you're in and also a different one if it's a combonation?


Some thing like this ;

if customer buys from product cat A they have to spend X dollars to get free shipping.

If in cat b spend Y dollars,



Why? I have product lines that are on the average $70-120 dollars per item like telelphone headsets. I want to say to this customer that if they buy a top and an Amp they get free shipping.

On the other hand I also have phone systems that are in the $1500+ range. They weigh a lot and I can't assign the same level of discount for free shipping to these items as to the 2 pound/$200 headsets.

Corwyn
delaen
I think that change would have a lot more to do with the way the free shipping mod works than it would have to do with this. A lot of other people have had the same problem and have posted a bunch of threads about it. You might want to search around on the board and see if anyone else was able to answer your question.
hose
biggrin.gif

Thanks for the excellent addition!
EnhanceYourVision.com
Hey, this sounds like a great feature! But I don't have the Shopping Cart box in my store? so instead I would like to add this feature to my shopping cart PAGE under the total price? So before they checkout they get a notice saying, "Hey, spend another $20 and you get free shipping!"

Is this possible, and if so how?

Thank you!
delaen
QUOTE
Hey, this sounds like a great feature! But I don't have the Shopping Cart box in my store? so instead I would like to add this feature to my shopping cart PAGE under the total price? So before they checkout they get a notice saying, "Hey, spend another $20 and you get free shipping!"

Is this possible, and if so how?

Thank you!


Add the line to english.php and then wherever you want the line to display, add:

QUOTE
if ($cart->show_total() < MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
$add_to_get_free_shipping = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER - $cart->show_total();
echo '<p>' . sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping));
}


It worked for someone in product_info.php. I don't see why it wouldn't work on any other page as well. Let me know if it doesn't.
EnhanceYourVision.com
Worked great!

Thanks Bob - Your a champ!
ptmorales
A newbie question, but can you tell me what contribution you are using to implement the free shipping? There seems to be more than one.

Thanks!
ptmorales
Please ignore the previous. Found it in admin/modules/order total - shipping.

It's late. laugh.gif
blazingfire
This is a great hack. I have installed it. But when I check out, I want to see my free delivery thingy being on the check out sheet itself at checkout_confirmation.php ... currently, it still charges the customer a delivery fee ...

It gets more complicated. It is only free for one delivery option and I have 3 delivery options ...

Please help. Thanks!

biggrin.gif

Please help. Thanks!
delaen
Well, this doesn't really calculate any shipping costs. It simply reads what value you have in your DB as the "Free Shipping" dollar amount, compares it to what's in the shopping cart, and displays the difference.

It sounds like you're having trouble with the actual calculation of the free shipping, which is a completely seperate issue. I think if you do a search you'll probably be able to find an answer though. Sorry I couldn't be of more help.
minglou
This is great mod.

thanks delaen!

1.
-----------------------------------------------------------------------------------------------
this is for who still using MS1 with Free Shipping w/ Minimum Amount

http://www.oscommerce.com/community/contributions,146/page,2


if ($cart->show_total() < MODULE_SHIPPING_FREECOUNT_AMOUNT) {
$add_to_get_free_shipping = MODULE_SHIPPING_FREECOUNT_AMOUNT - $cart->show_total();
$info_box_contents[] = array('align' => 'center',
'text' => sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping)));

}

change MODULE_SHIPPING_FREECOUNT_AMOUNT to MODULE_SHIPPING_FREECOUNT_AMOUNT

this will works with MS1 with Free Shipping w/ Minimum Amount
----------------------------------------------------------------------------------------------

2.
----------------------------------------------------------------------------------------------
since this mod only works only when customer add some items to shopping cart, and this words [ 'Add %s to your order and receive FREE shipping! ] display.
How can i set shopping cart default setting like this?
even customers don't add some items to cart, it still display [ Add %s to your order and receive FREE shipping! ] , that will be good since sometimes customers don';t know your website has free shipping unless they click add to cart button.

i tried to change this $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;

to this $cart_contents_string .= BOX_SHOPPING_CART_FREE_SHIPPING; but no good.

anyone help me?
---------------------------------------------------------------------------------------------

3.
----------------------------------------------------------------------------------------------
I set orders over $ 59.99 to receive free shipping, but if orders over $ 59.99, the shopping cart doesn't display anything, so cutomers may not know if he or she already receive free shipping unless they checkout.
so is possible to display this [ Congratulations! You have earned Free Shipping on this order! ] if they order over free shipping amount,

is this good for customers?

what about using IF ELSE to get this work?

we need help!!!

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


sean
thanks
minglou
Hi, delaen

By the way

which contribution did you use for your login.php?

your website: http://www.badmouthmovies.com


Thanks
sean
delaen
QUOTE (terran11355@yahoo.com @ Sep 20 2003, 10:21 AM)
This is great mod.

thanks delaen!

1.
-----------------------------------------------------------------------------------------------
this is for who still using MS1 with Free Shipping w/ Minimum Amount

http://www.oscommerce.com/community/contributions,146/page,2


if ($cart->show_total() < MODULE_SHIPPING_FREECOUNT_AMOUNT) {
$add_to_get_free_shipping = MODULE_SHIPPING_FREECOUNT_AMOUNT - $cart->show_total();
$info_box_contents[] = array('align' => 'center',
'text' => sprintf(BOX_SHOPPING_CART_FREE_SHIPPING, $currencies->format($add_to_get_free_shipping)));

}

change MODULE_SHIPPING_FREECOUNT_AMOUNT to MODULE_SHIPPING_FREECOUNT_AMOUNT

this will works with MS1 with Free Shipping w/ Minimum Amount
----------------------------------------------------------------------------------------------

2.
----------------------------------------------------------------------------------------------
since this mod only works only when customer add some items to shopping cart, and this words [ 'Add %s to your order and receive FREE shipping! ] display.
How can i set shopping cart default setting like this?
even customers don't add some items to cart, it still display [ Add %s to your order and receive FREE shipping! ] , that will be good since sometimes customers don';t know your website has free shipping unless they click add to cart button.

i tried to change this $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;

to this $cart_contents_string .= BOX_SHOPPING_CART_FREE_SHIPPING; but no good.

anyone help me?
---------------------------------------------------------------------------------------------

3.
----------------------------------------------------------------------------------------------
I set orders over $ 59.99 to receive free shipping, but if orders over $ 59.99, the shopping cart doesn't display anything, so cutomers may not know if he or she already receive free shipping unless they checkout.
so is possible to display this [ Congratulations! You have earned Free Shipping on this order! ] if they order over free shipping amount,

is this good for customers?

what about using IF ELSE to get this work?

we need help!!!

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


sean
thanks

All of those are really good ideas. I'm going to implement all of these changes early next week. If I do, I'll post the code.


And the login code is something I coded. I posted it in this thread: http://forums.oscommerce.com/index.php?sho...ic=31021&st=40#
Nils P.
Hi all,
I just found this interesting thread - I should have found it earlier though! I recently wrote a MS 2 contribution, Shopping Cart Box Enhancement , which includes a "tell customer how much more to spend for free shipping" feature. It takes into account the fact that a shopkeeper can set "free shipping" to "national", "international" or "both", which is an important feature for many shops, as I found out. I just uploaded a new version.
Here's the thread about it, if you're interested:
http://forums.oscommerce.com/index.php?act=ST&f=7&t=58263

Cheers,
Nils
blazingfire
Well, I like all these free shipping stuff and in fact it is super cool ...

But, I really need this free shipping stuff to work with my shipping costs thingy. Basically, I have 3 modes of delivery and if my customer were to shop > $25 worth of items, the default mode of delivery cost would change from $2.50 to that of $0.00. It would even be better if the amount 2.50 has a line across it to indicate that the delivery charge is cancelled ... Is this difficult to do?

Please help. Thanks!

~hoping that I made my problem clear for all~
MurrayM
Will this code work in MS2? Or is it for MS1 -- I have a cart built on each.
thanks,
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.