How to move Zen Cart to a new server – the easy way!

1. Copy site files and database
a) Use ftp and download entire zen cart directory to your local machine
b) Use ftp and upload entire zen cart directory to your new server
c) Head to your phpmyadmin and export your zen cart database to your local machine
d) Head to your phomyadmin on your new server and import the database file

2. Locating configure.php files – of which there are two.

One is in includes/configure.php and the other is in admin/includes/configure.php

I’ll use ‘store’ as our example – IE if you browsed to your site it would be http://www.mydomain.com/store

3. Adjusting the first config file: includes/configure.php

a) Find this code and replace details with your new domain name.
define(‘HTTP_SERVER’, ‘http://www.mydomain.com/store’);
define(‘HTTPS_SERVER’, ‘https://www.mydomain.com/store’);
define(‘HTTP_CATALOG_SERVER’, ‘http://www.mydomain.com’);
define(‘HTTPS_CATALOG_SERVER’, ‘https://www.mydomain.com’);

b) Find the code:

define(‘DIR_FS_CATALOG’, ‘/home/yourname/public_html/store/’);

and replace with your new path. If you’re unsure how to find your path, click here find out how here.

c) Find the code:

define(‘DIR_FS_SQL_CACHE’, ‘/home/yourname/public_html/store/cache’);

and change the path to suit here as well.

d) Change these connection details to your new server database.

define(‘DB_SERVER’, ‘localhost’);
define(‘DB_SERVER_USERNAME’, ‘yourusername’);
define(‘DB_SERVER_PASSWORD’, ‘yourpassword’);
define(‘DB_DATABASE’, ‘yourdatabasename’);
e) Copy the config file to your server

4. Working on the next config file: admin/includes/configure.php

a) Same again, replace the domain urls

define(‘HTTP_SERVER’, ‘http://www.mydomain.com’);
define(‘HTTPS_SERVER’, ‘https://www.mydomain.com’);
define(‘HTTP_CATALOG_SERVER’, ‘http://www.mydomain.com’);
define(‘HTTPS_CATALOG_SERVER’, ‘https://www.mydomain.com’);

b) Find this code:

define(‘DIR_FS_CATALOG’, ‘/home/yourname/public_html/store/’);

and replace with the correct path

c) Find this code:

define(‘DIR_FS_SQL_CACHE’, ‘/home/yourname/public_html/shop/cache’);

and replace with the correct path

d) Replace database connection details as before:

define(‘DB_SERVER’, ‘localhost’);
define(‘DB_SERVER_USERNAME’, ‘yourusername’);
define(‘DB_SERVER_PASSWORD’, ‘yourpassword’);
define(‘DB_DATABASE’, ‘yourdatabasename’);

e) Upload and replace file via FTP to the correct location

5) Last step – update session key.

Super simple, click here and head over to this site for a free quick tool that does it for you. Simple.

How to find the absolute path of your files using php

If like me you were trying to find the absolute path for your files when setting up your zen cart install, I found the following script to be super useful. Can be used anywhere, not just for zen cart!

Just make a blank php file in folder you want to get the path of and paste this:

<?php
$path = getcwd();
echo "This is the absolute path: ";
echo $path;
?>

Then just browse to the file and see the path. Quick ‘n easy!

FIXED: Zen Cart Broken when upgraded from php 5.2 to 5.3

Fixing a very broken Zen Cart when upgrading php to 5.3

Finally solved a problem that had been nagging on a site today, we found that a zen cart e commerce site was returning the white screen of death – it turned out to be the server having been upgraded to php 5.3 from 5.2.

Having searched the internet for people with similar issues, we found a few solutions that when combined together worked perfectly for us. I’m not a massive fan of zen cart or such tecchy systems, so I’m not the one to ask if you need further information from here. I’ll just show you the files I changed that made the site work again.. so PLEASE make sure you back up ALL your files before you get started, and I can’t b responsible for your site not working.

I was getting log files returning issues like this (amongst others!)
PHP Deprecated: Function set_magic_quotes_runtime() is deprecated

1. Find: “set_magic_quotes_runtime” and prefix with an ‘@’ in application_top.php
Found in: application_top.php and /admin/includes/application_top.php

2. Find “ereg(‘whatever’, $whatever)” and replace it with “preg_match(‘/whatever/’, $whatever)” don’t forget that there are added forward slashes in there, look at the code carefully.
Found in: includes/classes/db/mysql/query_factory.php
Example: “ereg(‘^[0-9]‘, $key)” should be replaced by “preg_match(‘/^[0-9]/’, $key)”

3. Find “date_diff” and replace it with something like zen_date_diff
Found in:
admin/orders.php
admin/includes/header.php
admin/includes/modules/orders_download.php
admin/includes/functions/general.php
includes/modules/payment/paypal/paypal_functions.php
includes/functions/functions_general.php

That’s all that I needed to get it working – so good luck if you try it.. let me know if it works for you.
I’ve got a list of the original links etc, so let me know if you need them. This link was the most helpful.

WordPress: Is your is_front_page() not working in your side bar?

If you’re modifying your sidebar in the wordpress sidebar and can’t get your is_front_page() or is_home() working… try adding a reset query just before. Worked for me.

IE I was adding a advert that would only show on the homepage of the wordpress blog, rather than throughout the entire website this should work fine. [Use the code at your own risk etc etc]

Automatic backup of you WordPress database – A decent plugin

I’ve been using the WP-DBManager plugin for over a year now, and it has reliably sent a copy of my database to me each morning at 8am – straight to my inbox. When you look after a million WordPress sites (I think I look after about 15-20 at the moment) this plugin is a surefire lifesaver. Don’t forget you still need to backup you files on your server, and don’t forget to backup your uploads folder… some people always forget this one!

Anyway – a worthwhile install, and certainly adds to a bit of piece of mind in the fast moving world of WordPress!

http://wordpress.org/extend/plugins/wp-dbmanager/

Good free URL redirection plugin for WordPress

If like me you have some sites that have a million links to sites, people, places and products you need to me able to manage them well. I stumbled across a redirection plugin for WordPress that seems to do the job pretty well. I’ve used this plugin for the last year or so on a couple of sites and has been super helpful. IMO the best use is for links that might change over time, you can update the target URL whenever you like and it won’t change your hard coded links in your website. So it means you can easily target broken links in the future, and you only have to change it in one place rather than hundreds. you just add a variable after go/yourquicklink and it’ll send it on from there. Very clever. Can also be used to tidy up affiliate links heading out your site, a much neater and better looking link, without any of the problems that are usually associated.

Have a look here at the (Free) GoCodes Plugin

Remove the default ‘category’ prefix from your wordpress URL

On new WordPress installs, I’ve used the plugin ‘Top Level Categories’ more than a few times, and can certainly recommend it. Just be aware when fiddling with your categories that sometimes it creates weird structures if you set up the individual categories first – the last time I used it I installed the plugin first, then assigned each post a new category. This seemed to solve the problem. I would suggest using the /%category%/%postname%/ permalink structure, and twinned with an SEO plugin controller you’ll have pretty good control over your URL and site structure… best to get it as soon as possible before you make too many pages!

Top Level Categories

Removes the prefix from the URL for a category. For instance, if your old category link was /category/catname it will now be /catname

Zen Cart – Change the template design on the home page only

Here’s a little one I found that might simplify things for you. I wanted to override the homepage template on the index page of a zen cart powered website, basically so I could show a big ad type image on the homepage under the navigation, so that it would appear on teh homepage only, like a big call to action / visual impact to start the visitors journey off. I needed it to load in the top section of the code, rather than the individual content pages so I needed to make the changes in the tpl_main_page.php main page template file.(tpl_main_page.php in your /yourtheme/common/ folder)

I duplicated the header file and made my template adjustments, and then using a bit of php told the site that when it loads, check the pagename – and if the pagename is ‘homepage’ then load the modified headerfile (tpl_header_home.php) – and if it’s anything other than homepage, just load the original.

Anyway, after a bit of fiddling around I found this to work pretty well.

<?php /* ----- prepares and displays header output ----- */

  if ($this_is_home_page) {
    require($template->get_template_dir('tpl_header_home.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header_home.php');
  }
  else
  { require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');}

?>