Jump to content

Archived

This topic is now archived and is closed to further replies.

sagitario

Add to cart message

Recommended Posts

Hi,

 

Anyone know a way to display a pop up message when a customer adds a product to the shopping cart?

 

I have disable the option "Show shopping cart after adding a product" and when a customer click in "Add to Cart" Button the product is add to the shopping cart and the customer remain in the product info page. The idea is to after click in "Add to cart" button that a message will pop up informing the customer that a new product was be add to the shopping cart.

 

Sorry my bad english. :blush:

 

Regards,

Share this post


Link to post
Share on other sites

At the top of /catalog/index.php AFTER this code:

 

  require('includes/application_top.php');

 

ADD this code:

 

  if ( ! tep_session_is_registered('OldCartCount') ) {
   $OldCartCount = 0;
   tep_session_register('OldCartCount');
 }

Then in /catalog/product_info.php BEFORE the </body> tag ADD this code:

 

<?php
 if ( $cart->count_contents() > $OldCartCount ) {
   $OldCartCount = $cart->count_contents();
?>
<script type="text/javascript">
 my_window = window.open("","mywindow","status=1,width=350,height=100");
 my_window.document.write('<H1>The item was added to the shopping cart</H1>');
 var t=setTimeout("my_window.close()",3000)
</script>
<?php
 }
?>

I tried this and it works.

 

The window is programmed to close after 3 seconds.

 

If you want to change that time just change the number 3000 in the code (hint: 1000 = 1 second).

 

BACKUP THE FILES BEFORE MAKING EDITS.


If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Share this post


Link to post
Share on other sites

Hi again,

 

I try it and work in IE but not in FF.

 

I will try to change the code to adapt to the way I want. I'm trying to make a cool popup, using maybe lightbox effect.

 

Thanks for the help.

 

Regards,

Share this post


Link to post
Share on other sites

It does work in FireFox.

 

Another way to use Jums method is to add the below in catalog/includes/application_top.php right before the closing " ?> ".

 if ( ! tep_session_is_registered('OldCartCount') ) {
   $OldCartCount = 0;
   tep_session_register('OldCartCount');
 }

In catalog/includes/functions/general.php right before the closing " ?> " add the following function.

 function tep_addCartPopup() {
   global $cart, $OldCartCount;

   if ( $cart->count_contents() > $OldCartCount ) {
     $OldCartCount = $cart->count_contents();
     $output = '<script type="text/javascript">
 my_window = window.open("","mywindow","status=1,width=350,height=100");
 my_window.document.write("<H1>The item was added to the shopping cart</H1>");
 var t=setTimeout("my_window.close()",3000)
</script>' . "\n";
   }
   return $output;
 }

Then on all pages that you can add an item from, index.php product_info.php product reviews pages, add the following right before the " </body> " tag.

<?php echo tep_addCartPopup(); ?>


Remember to backup database, files and pictures.

 

I have a problem for your solution

I reject your reality and substitute my own

My mind not only wanders, it sometimes leaves completely

The problem with the gene pool is that there is no lifeguard

Everyone’s entitled to my opinion

 

Links

Security

SSL Help

Basics for design V2.3+

Share this post


Link to post
Share on other sites

It works in Firefox for me as well.


If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Share this post


Link to post
Share on other sites

×