View Single Post
  #20  
Old 08-17-2009, 02:09 AM
 
autobulbs autobulbs is offline
 

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

Default Re: Popup - Item Added to Cart

4.2.2 Basket Popup Code

I think it's all here, and I've had to sift thru it to remove our theme specific junk. Read the comments within the CSS and TPL files

Go to Patch/Upgrade and then Apply SQL Patch and run this:

Code:
INSERT INTO `xcart_modules` (`module_name`,`module_descr`,`active`) VALUES ('Item_Added','This module popups when a customer adds something to the basket. Remember to set redirect customer to cart to N','N');


Create modules/Item_Added/item_added.php and put this in it:

PHP Code:
<?php
  
/* Item Added Popup */
  
x_session_register("item_added");
  
$smarty->assign("item_added","$item_added");
  
x_session_unregister("item_added");
  
/* /Item Added Popup */
  
?>


Open home.php and find this:

PHP Code:
# Assign the current location line
  
$smarty->assign("location"$location); 

Add this before it:

PHP Code:
# Item Added Module
  
if (!empty($active_modules["Item_Added"]))
              include 
$xcart_dir."/modules/Item_Added/item_added.php"


Open product.php and find this:

PHP Code:
# Assign the current location line
  
$smarty->assign("location"$location); 

Add this before it:

PHP Code:
# Item Added Module
  
if (!empty($active_modules["Item_Added"]))
              include 
$xcart_dir."/modules/Item_Added/item_added.php"

Open cart.php and find this ( around line 258 ):

PHP Code:
func_save_customer_cart($login$cart); 

Paste this below it:

PHP Code:
/* Item Added Popup */
                          
x_session_register("item_added");
                          
$item_added=1;
                          
/* /Item Added Popup */ 

Open skin1/customer/menu_cart.tpl and paste this after {capture name=menu}

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

Open main.css and add this code (edit to fit your theme):

Code:
/* The popup wrapper, brings the element to the front */ .item_added { position:absolute; width:1px; height:1px; text-align:left; } /* The popup inner wrapper, positions the popup √ you can fine tune it here */ .item_added > div { position:relative !important; display:block; top:24px; z-index:9999; left:-24px; } /* The main body of the popup change the bg color or use an image */ #basketPopup { background:#e1e1e1; height:216px; width:210px; color:#484848; padding-left:54px; } #basketPopup div { color:#fff !important; } #basketPopup a { color:#fff !important; text-decoration:underline; } /* The popup main title */ #basketPopup .basketPopupTitle { font-weight:bold; font-size:13px; text-align:right; width:162px; padding:12px 0; float:left; } #basketPopup #basketClose { /* The bg image is commented here and replaced with an ▒X▓ √ feel free to replace with an image */ /* background:url(images /btn_close.gif) no-repeat; */ height:14px; width:14px; float:left; margin: 8px 0 0 16px; cursor:pointer; } /* Keep shopping / View Basket buttons */ #basketPopup .basketPopupButtons { clear:left; } /* Use this for an arrow image which links the popup to the minicart √ you will need to make an image */ #basketJoiner { width:232px; text-align:right; padding-right:32px; margin-bottom:-1px; }


Create skin1/customer/item_added.tpl and put this in it

Code:
{* Remember to create the joiner.jpg image to fit your theme!! *} <div id="basketJoiner"><img src="{$ImagesDir} /joiner.png" alt="" /></div> <div id="basketPopup"> {* The title of the popup *} <div class="basketPopupTitle">Item Added To Basket</div> {* The close button √ Remove the X and replace with an image *} <div id="basketClose" onclick="javascript:item_added_close();">X</div> {* The buttons view basket and keep shopping buttons, make your images to fit your theme *} <div class="basketPopupButtons"><a href="/cart.php"><img src="{$ImagesDir}/BasketPopup/btn_basket.gif" alt="View Basket" /></a> <a href="javascript:item_added_close();"><img src="{$ImagesDir}/keepshopping.gif" alt="Keep Shopping" /></a></div> </div>


One more thing - Open skin1/common.js and add this:

Code:
/* When something is added to the cart... Close it.... */ function item_added_close() { document.getElementById('item_added_box').style.display="none"; }

When you are happy to set it live, go to modules within the admin section, check Item_Added and click update to enable it
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote