View Single Post
  #3  
Old 09-20-2012, 07:16 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Add to Cart Popup | Backporting to 4.4.X

Step 2
Now we are going to edit some files, to include the module functionality in the existing PHP files and templates. Be sure to create a backup of the existing file before you edit it. I like to name my backup files something meaningful like filename.extension.bak.Add_to_cart_popup so I can identify what I was doing when I edited that file.

Edit /cart.php:
Find:
PHP Code:
func_register_ajax_message(
        
'cartChanged',
        array(
            
'changes'     => array(
                
$result['productindex'] => array(
                    
'productid' => $add_product['productid'],
                    
'quantity'  => $result['quantity'],
                    
'changed'   => $result['changed'],
                )
            ),
            
'isEmpty' => empty($cart['products']) && empty($cart['giftcerts']),
            
'status'  => $result['status'],
        )
    ); 

After add:
PHP Code:
if (!empty($active_modules['Add_to_cart_popup'])) { 
        
func_add_to_cart_popup($productid$add_product$result['productindex']); 
    } 

Before:
PHP Code:
// Redirect
    
if (
        
$config['General']['redirect_to_cart'] == 'Y'
        
|| isset($_GET['redirect_to_cart'])
    ) 
Edit /include/data_cache.php:
Find:
PHP Code:
function func_sort_active_modules($a$b)
{
    static 
$sort_order = array(
        
'Discount_Coupons' => 1#independent module 
After add:
PHP Code:
'Add_to_cart_popup' => 1#independent module 
Before:
PHP Code:
'Egoods' => 1#independent module 
Note: It doesn't seem to matter where in the list this snippet gets placed and editing this file may not be completely necessary, I'm just being careful to copy the 4.5.X code here.

Edit /include/product_modify.php:
Find:
PHP Code:
if (!empty($active_modules['Recommended_Products'])) {
            
func_refresh_product_rnd_keys($productid);
        } 
Change it to:
PHP Code:
if (
            !empty(
$active_modules['Recommended_Products'])
            || !empty(
$active_modules['Add_to_cart_popup'])
        ) {
            
func_refresh_product_rnd_keys($productid);
        } 
Edit /include/func/func.product.php:
Find:
PHP Code:
// Generate ORDER BY rule

    
if (empty($orderby)) {

        
$orderby $config['Appearance']['products_order']
            ? 
$config['Appearance']['products_order']
            : 
'orderby';

        if (!empty(
$orderby_rules))
            
$orderby $orderby_rules[$orderby];
    
    } 
After add:
PHP Code:
elseif ($orderby == 'skip_orderby') {
        
$orderby '';
    } 
Before:
PHP Code:
// Initialize service arrays 
Edit /skin/common_files/customer/service_js.tpl:
Find:
HTML Code:
{include file="onload_js.tpl"} {if $config.UA.browser eq "MSIE"} {assign var=ie_ver value=$config.UA.version|string_format:'%d'} {if $ie_ver lt '7'} {load_defer file="customer/iefix.js" type="js"} {/if} {/if}
After add:
HTML Code:
{if $active_modules.Add_to_cart_popup ne ''} {load_defer file="modules/Add_to_cart_popup/product_added.js" type="js"} {/if}
Note: You may need to make this change in your custom skin directory, check your skin and see if this file exists. Even if it doesn't you can create it there, and copy the contents of the common_files tpl before making the change. I like this as it keeps your changed templates in your custom skin folder for easy identification later.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote