X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Popup - Item Added to Cart (https://forum.x-cart.com/showthread.php?t=46934)

autobulbs 04-14-2009 07:08 AM

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 04-16-2009 03:40 AM

Re: Popup - Item Added to Cart
 
This has now been solved - i used cookies

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

autobulbs 04-16-2009 04:15 AM

Re: Popup - Item Added to Cart
 
Just thought I would share this solution (mainly so I can refer to it myself :D)

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 :D

Regards
- Nick


Quick Edit:
You will need to uncheck "redirect to cart" in general options

Learner 04-16-2009 04:16 AM

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?

balinor 04-16-2009 04:20 AM

Re: Popup - Item Added to Cart
 
Moving to Custom Mods :)

autobulbs 04-16-2009 05:02 AM

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

Learner 04-17-2009 04:36 AM

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.

autobulbs 04-17-2009 05:44 AM

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

Learner 04-17-2009 09:29 PM

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.

TanyaG 04-23-2009 02:04 AM

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


All times are GMT -8. The time now is 12:54 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.