Google

Monday, March 9, 2009

Zen Cart & Wordpress Integration

 

 

WordPress is an extremely powerful and widely used open-source blogging platform. It has a wide community of developers and users, and almost all kinds of plugins are available for it. Although there are some shopping cart plugins for WordPress, they are not full-blown shopping carts like Zen Cart or osCommerce. E-commerce plug-ins available for WordPress have limited features.

Those who are running blogs using WordPress may want to integrate it with Zen Cart to provide e-commerce functionality to their blogs. In fact, there is a Zen Cart module for integrating these two. You can download that module from www.zen-cart.com.

After downloading the plug-in WordPress on Zen Cart, you have to install it on the webserver. You can install the plug-in in two ways: first, in an environment where you have a working WordPress installation, and second, when you have not installed WordPress.

WordPress and Zen Cart Installed in Separate Directories

When you have an existing installation of WordPress, generally it will be in a separate directory from that of the Zen Cart installation. If your web document root directory is public_html, then the installation directories may be: /public_html/blog and /public_html/shop. Follow these procedures to install WordPress on Zen Cart plug-in:

Step1: Install WordPress

If you have not installed WordPress yet, then download the WordPress files from www.wordpress.org and unzip the files. Then, upload the files to your webserver’s /public_html/blog directory. Now, change the permission of this directory to 777 and point your browser to http://yourdomain.com/blog/wp-admin/setup-config.php. The installation wizard for WordPress will be displayed. Follow the instructions on the wizard and give the necessary information. Once all of the information is given, WordPress will be installed.

Step 2: Configure WordPress

During installation, an administrative account will be created. Note the username and password for this account. Then, point your browser to http://yourdomain.com/blog/wp-admin/. The login page will be displayed. Type the username and password for the administrative account and click on the Login button.

You will see the dashboard for administering WordPress. Go to Options | General. Now, change the Blog Address (URL) to Zen Cart’s URL http://yourdomain.com/shop/. From the administration dashboard, go to Presentation | Themes and select WordPress Default 1.6.

Step 3: Upload WordPress on Zen Cart

When you unzip the WordPress on Zen Cart plug-in zip file, you will find that there is a directory called ZC_ROOT and WP_ROOT. Now, upload the contents of ZC_ROOT directory to Zen Cart’s installation path on the server, that is, /public_html/shop/. Similarly, upload the contents of the WP_ROOT directory to WordPress’ installation path, that is, /public_html/blog. Before uploading the contents of the ZC_ROOT directory, please change the name of the /ZC_ROOT/includes/templates/MY_TEMP/ directory to that of the template directory you are using for your Zen Cart shop

Step 4: Edit WordPress File

For older versions of WordPress, you may need to edit the /wp-include/template-loader.php file. Open the file in a text editor and replace all exit; with return;. However, you may not need this for the newer versions of WordPress. WordPress 2.3.1 can work without this modification. First, try without this modification.

Step 5: Edit Zen Cart File

You also need to edit another file in the Zen Cart installation. Open the /includes/extra_configures/wordpress-config.php file under the Zen Cart installation folder and find the following line:

define ('ABSPATH','/var/www/vhost/example.com/public_html/blog/');



Type the appropriate WordPress path, that is, /home/username/public_html/blog/. The above line will look like this:




define ('ABSPATH','/home/public_html/blog/');



If you are trying it on Windows, you may need to put the absolute path, as in, e:/www/blog.



Step 6: Configure Sideboxes from Layout Boxes Controller


Once the file modifications have been done, login to the Zen Cart administration panel. Go to Tools | Layout Boxes Controller. The screen will notify you that some new sideboxes-wp_cats.php, wp_archives.php, wp_pages.php, wp_links.php, and wp_sidebar.php-have been found. To use these sidebars, click on the reset button at the bottom. To show these sideboxes on your Zen Cart shop, click on the sidebar and change its left/right column status.



Step 7: Test your Integration


Now, it’s your time to see how the Zen Cart and WordPress integration works. Point your browser to your Zen Cart shop, that is, http://yourdomain.com/shop/. If everything is okay, you will find the screen as shown in the following screenshot:



If the ABSPATH value in wordpress-config.php file is not entered appropriately, you will get a message saying that wp-config.php file in a particular path is not found. In that case, edit the wordpress-config.php file and enter the correct path to the WordPress installation.



Note that a left sidebox named Blog Sidebar is shown in your Zen Cart shop. You will find links to pages in the blog, links to archives, and links to categories. Click on a link and that category, archive or page will be displayed.



You may be disappointed when you look at the result because the whole WordPress page with headers, footers, and sidebars is displayed. If you have some knowledge of customizing WordPress themes, you can work out a nice solution by removing the header, the footer, and the sidebar from the theme layout.



For learning WordPress theming, check the excellent tutorials at www.wordpress.org. You can also read WordPress Themes, published by Packt.





WordPress and Zen Cart Installed in the Same Directory



You can also install WordPress and Zen Cart in the same directory. In such a case, install Zen Cart first. Configure it for normal use, and then proceed with the installation of WordPress. For example, if your Zen Cart installation is in /public_html/shop/, then WordPress will also be installed at /public_html/shop/. First, download the WordPress installation package, unzip it, and upload all files, except index.php.



After uploading the files to the Zen Cart directory, i.e. /public_html/blog/, change the access permission of these to 777. Now, point your browser to http://yourdomain.com/shop/wp-admin/setup-config.php. The installation wizard for WordPress will be displayed. Follow the instructions of the wizard and provide the necessary information. Once all information is made available, WordPress will be installed.



Now, follow Steps 2 to 7 as described in the previous section. In this case, the paths to Zen Cart and WordPress will be same.

1 comment:

Curtis said...

Nice one guys! We might try to work a reference to this one into our blog post about how to integrate wordpress later next week.

how to integrate wordpress