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

Add to Cart Popup | Backporting to 4.4.X

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-20-2012, 07:01 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

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

Default Add to Cart Popup | Backporting to 4.4.X

I think one of the juiciest features of 4.5.X is the addition of the new Add_to_cart_popup module. It is the best of both worlds. Traditionally you have to choose whether you want to redirect to cart and possibly lose out on additional impulse buying, or keep them on page with the ajax cart update and potentially confuse your visitor about whether the item is added or not. I have seen most of the bigger brands out there adopt this popup method. It also gives you an option for upselling.

So what do users with 4.4.X do? Upgrade their highly customized carts? No longer!

I have been contracted to backport this module to a 4.4.4 site, and I am going to track my progress and steps in this thread. Stay tuned!
__________________
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

The following 4 users thank totaltec for this useful post:
ADDISON (09-21-2012), cherie (09-21-2012), chris.ath (11-05-2012), Marc Washburn (01-26-2013)
  #2  
Old 09-20-2012, 07:08 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 1
Download a 4.5.X distribution from your Qualiteam helpdesk. We need to get the files for the module.

The two folders you are looking for are:
/modules/Add_to_cart_popup/
and
/skin/common_files/modules/Add_to_cart_popup/

Copy the contents of these two folders and place them in your xcart directory, being sure to keep the paths and folder structure intact.

While you are at it, grab this file too: /include/func/func.minicart.php

It helps if you create a folder on your computer that mimics the site structure and contains all the new files and the ones we are going to edit in the next step. This will let you upload all your changes to your dev site in one step, and after testing you can do the same for your live site.
__________________
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
  #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

The following 2 users thank totaltec for this useful post:
chris.ath (11-05-2012), MAPerformance (02-26-2013)
  #4  
Old 09-20-2012, 09:36 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 3
Now we need to update the database with the module settings and added language variables. To do this visit Tools > Patch/Upgrade section of your X-cart admin. Look under the heading "Apply SQL Patch".

In the text box labeled SQL query(ies) paste these queries:

INSERT INTO xcart_config VALUES ('enable_upselling','Upselling products','Show_Both','Add_to_cart_popup',10,'sele ctor','Show_Both','Show_Random:lbl_show_randomly_s elected_products\nShow:lbl_show_upselling_products \nShow_Both:lbl_show_upselling_and_random\nHide:lb l_do_not_show_upselling_products','');
INSERT INTO xcart_modules VALUES (98,'Add_to_cart_popup','This module allows your customers to see what they have added to cart along with upselling products.','Y');
INSERT INTO xcart_languages VALUES ('en','module_name_Add_to_cart_popup','Add To Cart Popup','Modules');
INSERT INTO xcart_languages VALUES ('en','lbl_show_upselling_and_random','Show upselling + random products','Labels');
INSERT INTO xcart_languages VALUES ('en','lbl_show_randomly_selected_products','Show random products','Labels');
INSERT INTO xcart_languages VALUES ('en','lbl_show_upselling_products','Show upselling products','Labels');
INSERT INTO xcart_languages VALUES ('en','lbl_do_not_show_upselling_products','Do not show additional products','Labels');
INSERT INTO xcart_languages VALUES ('en','lbl_item_added_to_cart','item added to cart','Labels');
INSERT INTO xcart_languages VALUES ('en','lbl_items_added_to_cart','items added to cart','Labels');
INSERT INTO xcart_languages VALUES ('en','lbl_proceed_to_checkout','Proceed to checkout','Labels');

Alternatively you can use phpMyAdmin for this task, or download the file attached to this post and upload it using the "Patch File" Upload button. (you may need to rename it to .sql instead of .txt, not sure haven't tried it yet)
Attached Files
File Type: txt Add_to_Cart.txt (1.3 KB, 48 views)
__________________
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

The following 2 users thank totaltec for this useful post:
chris.ath (11-05-2012), MAPerformance (02-26-2013)
  #5  
Old 09-20-2012, 02:22 PM
  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

You're Done!

You may want to run yoursite.com/cleanup.php. Now you can go to Settings > Modules and you should see Add To Cart Popup at the top of the list. If you don't then you might have forgotten to run the sql patch above.

Good luck, hope it helps. Mike White, signing off...
__________________
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

The following user thanks totaltec for this useful post:
chris.ath (11-05-2012)
  #6  
Old 09-20-2012, 11:42 PM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

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

Great job Mike. Keep going!
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote

The following user thanks ADDISON for this useful post:
totaltec (09-20-2012)
  #7  
Old 09-21-2012, 11:49 AM
  Toora Designs's Avatar 
Toora Designs Toora Designs is offline
 

eXpert
  
Join Date: Aug 2011
Location: California USA
Posts: 281
 

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

Very nice Mike and thank you! Going to bookmark this thread
__________________
If you need professional help on your x-cart site or any website.
Feel free to PM me or Skype me to discuss your project.
Reply With Quote

The following user thanks Toora Designs for this useful post:
totaltec (09-21-2012)
  #8  
Old 10-22-2012, 03:21 AM
  carlisleglass's Avatar 
carlisleglass carlisleglass is offline
 

eXpert
  
Join Date: Aug 2003
Location: Carlisle, UK
Posts: 316
 

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

Excellent

Just make sure "Redirect customer to cart after adding a product" (Setting/General) is switched off, or you'll never see the popup! Took me about 15 minutes to work that one out
__________________
Darren Kierman
Carlisle Glass (http://www.carlisleglass.co.uk/)
... running X-Cart Gold 4.4.5 [unix]
Reply With Quote

The following 3 users thank carlisleglass for this useful post:
carpeperdiem (10-30-2012), MAPerformance (02-26-2013), totaltec (10-22-2012)
  #9  
Old 10-30-2012, 05:24 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

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

Quote:
Originally Posted by carlisleglass
Excellent

Just make sure "Redirect customer to cart after adding a product" (Setting/General) is switched off, or you'll never see the popup! Took me about 15 minutes to work that one out

I'm using 4.5.3 gold plus and this switch caused me 12+ hours of insanity.

see: http://forum.x-cart.com/showthread.php?t=65209

THANK YOU for pointing this out!!!

I have been searching the forum in every way, and this did not show up.

GEEZ -- turning this switch OFF should be a FRONT AND CENTER WARNING in the Add To Popup documentation, you think? If this switch is set, the module will not function. Hopefully, this thread helps someone searching.

For the search engines:

Add To Cart Popup
Not Working
Redirect customer to cart after adding a product setting

THANK YOU, THANK YOU THANK YOU!!!
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #10  
Old 01-24-2013, 06:59 PM
 
stagshop stagshop is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 32
 

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

I hope someone is still paying attention to this thread. I'm currently trying to modify products_t.tpl to remove all the <table> related tags so I can use <div> tags instead. If I do this, clicking the Buy Now button will add products to the cart, but the Add To Cart popup box no longer open. It seems that the popup module relies on <table> codes? Anyone have any insight as to why this might be, and better yet, which other files I need to modify?
__________________
x-cart v 4.5.4
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 04:44 AM.

   

 
X-Cart forums © 2001-2020