sagitario Posted April 27, 2010 Share Posted April 27, 2010 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, Link to comment Share on other sites More sharing options...
germ Posted April 28, 2010 Share Posted April 28, 2010 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 > Link to comment Share on other sites More sharing options...
sagitario Posted April 29, 2010 Author Share Posted April 29, 2010 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, Link to comment Share on other sites More sharing options...
Guest Posted April 29, 2010 Share Posted April 29, 2010 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(); ?> Link to comment Share on other sites More sharing options...
germ Posted April 29, 2010 Share Posted April 29, 2010 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 > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.