Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Popup - Item Added to Cart

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-14-2009, 07:08 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Popup - Item Added to Cart

Edit (18/8/09): For 4.2.2 code refer to this post

Hi,

I am trying to put in a popup message telling a user when they have added an item to the cart.

I have done this successfully on http://www.hids4u.co.uk

What you may notice about this is that it isn't using SEF URL's, simply because it causes a 404 error. I am using XC_SEO Basic and have been hacking around in it all day but had no success.

The conflict comes from something added to the URL redirect in cart.php that tells a bit of javascript in menu_cart.tpl to display the pop up, which XC_SEO doesn't like.

Does anyone know how to either incorporate an addition to the URL in XC_SEO or know of an alternative method for getting this to display?

Thanks
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #2  
Old 04-16-2009, 03:40 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Popup - Item Added to Cart

This has now been solved - i used cookies

Preview at http://www.autobulbsdirect.co.uk
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #3  
Old 04-16-2009, 04:15 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Popup - Item Added to Cart

Just thought I would share this solution (mainly so I can refer to it myself )

Firstly, in cart.php around line 240 find: func_save_customer_cart($login, $cart);

and put this underneath it:
Code:
setcookie("item_added", "true", time()+10);

In init.php at around line 690 add this:

Code:
$item_added_cookie = $_COOKIE["item_added"]; setcookie("item_added", "", time()-100); $smarty->assign("item_added","$item_added_cookie");

In menu_cart.tpl at line 2 add this:

Code:
{if $item_added eq "true"} <div class="item_added" id="item_added_box"><div>{include file="customer/item_added.tpl"}</div></div> {/if}

Create item_added.tpl in skin1/customer and put this in it:
(replace the buttons with you're own)
Code:
<table cellpadding="0" cellspacing="0" border="0" class="basket_popup"> <td align="center"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td height="16" align="right"><a href="javascript:item_added_close();"}><div style="height:16px; width:50px; cursor:pointer;"></div></a></td> </tr> <tr> <td valign="bottom" height="36" style="padding-left:16px;" align="left"><a href="cart.php" class="viewBasket">View Basket</a></td> </tr> <tr> <td valign="bottom" align="center" height="32"> <a href="javascript:item_added_close();"}><img src="{$ImagesDir}/KeepShoppingBtn.gif" /></a> &nbsp; <a href="/cart.php"}><img src="{$ImagesDir}/CheckoutBtn.gif" /></a> </td> </tr> </table> </td> <td width="8">&nbsp;</td> </tr> </table>

In common.js at the bottom add this:

Code:
function item_added_close() { document.getElementById('item_added_box').style.display="none"; }

Finally, in skin1.css at the bottom add this:
(again, you will need to replace any images/stying to suit you're site)
Code:
.item_added { position:absolute; width:1px; height:1px; } .item_added div { position:relative !important; display:block; left:-308px !important; top:-148px; } .basket_popup { background:url(/skin1/images/BasketPopup.png) no-repeat; height:170px; width:312px; }

I think that's everything. It could be made much tidier, but this is just somthing I whipped up

Regards
- Nick


Quick Edit:
You will need to uncheck "redirect to cart" in general options
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #4  
Old 04-16-2009, 04:16 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Popup - Item Added to Cart

Quote:
Originally Posted by autobulbs
This has now been solved - i used cookies

Preview at http://www.autobulbsdirect.co.uk

Thanks autobulbs for your effort.
Also is it possible to insert a close button and the small red window scroll through the page?
__________________
4.6.1 Platinum


Reply With Quote
  #5  
Old 04-16-2009, 04:20 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Popup - Item Added to Cart

Moving to Custom Mods
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #6  
Old 04-16-2009, 05:02 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Popup - Item Added to Cart

Quote:
Originally Posted by Learner
Also is it possible to insert a close button and the small red window scroll through the page?

Yes it is, I think the code is in there. It is within item_added.tpl:

Code:
<td height="16" align="right"><a href="javascript:item_added_close();"}><div style="height:16px; width:50px; cursor:pointer;"></div></a></td>

It just needs to be repositioned slighty. I took this actual bit from previous work i did where the box was a bit smaller (on the HIDS4U site mention in the first post).

I was toying with the idea of making that area link to the basket but decided not to.

I am now going to make it disappear/fade away if not closed within 10 seconds.

Edit: I think I mis read your post!

At the moment it is fixed in position, I will work on making it move with the page
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #7  
Old 04-17-2009, 04:36 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Popup - Item Added to Cart

Thanks autobulbs for your codes.

But some problems are-1) It is not working on IE only works on Mozilla.
2)javascript:item_added_close() not working.

please help me.

Thanks to all.
__________________
4.6.1 Platinum


Reply With Quote
  #8  
Old 04-17-2009, 05:44 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Popup - Item Added to Cart

Quote:
Originally Posted by Learner
But some problems are-1) It is not working on IE only works on Mozilla.
2)javascript:item_added_close() not working.

Change
Code:
<a href="javascript:item_added_close();"}><div style="height:16px; width:50px; cursor:pointer;"></div></a>

To
Code:
<a href="javascript:item_added_close();" style="height:16px; width:50px; cursor:pointer; display:block;"></a>

In item_added.tpl
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #9  
Old 04-17-2009, 09:29 PM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Popup - Item Added to Cart

Quote:
Originally Posted by autobulbs
Change
Code:
<a href="javascript:item_added_close();"}><div style="height:16px; width:50px; cursor:pointer;"></div></a>

To
Code:
<a href="javascript:item_added_close();" style="height:16px; width:50px; cursor:pointer; display:block;"></a>

In item_added.tpl

Thanks autobulbs for your reply.But this close code again also not working.The codes are working well on Mozilla only.Is it possible to work universally on all browsers(IE,Opera,Chrome)?

Thanks to all again.
__________________
4.6.1 Platinum


Reply With Quote
  #10  
Old 04-23-2009, 02:04 AM
 
TanyaG TanyaG is offline
 

Advanced Member
  
Join Date: Nov 2007
Posts: 94
 

Default Re: Popup - Item Added to Cart

Hi Autobulbs. Thanks so much for a great mode. I have one problem. I▓m using Buy Together module. Not sure if you are familiar with it but when I▓m adding bundle into basket popup note doesn▓t display. Any idea?

Many thanks
__________________
Tanya

x-cart version: 4.1.7 4.1.9. 4.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:31 AM.

   

 
X-Cart forums © 2001-2020