X-Cart 4.3 to 4.4

View Comments
x-cart dashboard

One of the web development companies that I program websites for has a thing for using X-Cart for their clients in need of e-commerce. Being me, I prefer to use the latest version of any application that I make use of. The company that I work for had a particular outdated version that they preferred, but I convinced them to switch to the newest version, at least for their newer clients. Sadly, that decision has proven to be a bit more difficult than I had hoped.

X-Cart Software

For those who have never heard of or made use of X-Cart, X-Cart is a PHP-based shopping cart application. It is designed with the ability to run large online shops with large amounts of categories and products. This is made clear by the inability to simply browse products without filtering them, first. Also, I have yet to discover the way to create products that do not exist in categories, which would be useful for shops that only have very few products with a lot of variations. And, to top it off, they use the Smarty template engine. Maybe it’s the hardcore PHP programmer in me speaking, but I’m not a fan of template engines, especially Smarty. At least, that’s my personal opinion. It’s not all bad though. I do like the way that products can be organized and updated in bulk. I also like their newest version, 4.4.

X-Cart Version 4.4 is a re-factored version of the old X-Cart software. All of their code was changed to boost performance and readability at the same time. Beforehand, they were using double-quotes on all strings, they were not using any whitespace when concatenating strings, the lines were excessively long (the SQL queries, in particular), and their “error checking” was no more than using the at sign (@) to suppress error messages. In addition to improving the code, they also gave the administration a much-needed face-lift, as well, making the menus much easier to navigate. It’s too bad that all of the documentation that I run across while search Google references the old navigation menus and not the new ones.

Using add-ons designed for older versions in 4.4

The latest X-Cart installation that we were working on required a lot of custom things. The client is a printing company that is using the shopping cart in order to sell printed products such as business cards and flyers. One of the requirements of every sale is a graphic to put on these products. I can only assume that the majority of their customers purchase customized printed products rather than the default template in the images. Considering file uploads are common in web development, I felt assured that I would easily find an X-Cart add-on to do the job.

In my searches, I found two add-ons that allowed file uploading as a customization option for products. One of them was compatible with X-Cart versions 4.0, 4.1, and 4.2, and the other was compatible with X-Cart versions 4.1, 4.2, and 4.3. I was aware that the change from 4.3 to 4.4 was a big jump, but I didn’t think it’d be so big that even add-on authors weren’t supporting it, yet. Eventually, I caved and we purchased the product that worked up to version 4.3. Then, the workload for making it compatible with version 4.4 was dropped onto my lap.

Firstly, let me say that X-Cart doesn’t seem to be designed in a manner that allows it to be easily extensible. I say this because, in order to install this add-on, I had to modify at least 20 files. X-Cart does have support for modules, and the bulk of this add-on was the module. However, the bulk of the labor was wrapped up in editing the core files.

The website from which got the add-on provided a very detailed change log, of sorts, that showed all of the portions of the core files that needed to be edited, and the code to add or remove. This was done primarily for developers who were already modifying their core files, allowing them to install the add-on without potentially breaking their files with an automated installation. Luckily, it loosely applied to users with newer versions of X-Cart as well.

The updating process

When X-Cart 4.4 was re-factored, a lot of code was moved around, but most of it was just reformatted. The change log that I was using gave the name of the file I would need to edit, the line number that it should be located on, and a few lines of code before and after the new snippet. The first file proved that not only would the line numbers be incorrect, but that some of the code would be separated into different files. As a proud user of Notepad++, I would search for the code that should be before or after the snippet (whichever was most recognizable) in the file that it should be in. Then, if I didn’t find it or I was convinced it was elsewhere, I’d use Notepad++ to search the entire folder.

There were a few things that I had to note about the refactoring:

  1. Almost all double-quotes were converted to single-quotes. While this should lighten the load on the PHP parser, it meant that I had to do the same thing for my search strings. The few times that this did not apply was in SQL queries, and sometimes when a file was included or required.
  2. Horizontal and vertical whitespace was added. This greatly improved the readability, especially on line lines, but it made my search queries less specific than they could have been. I did the best with what I had.
  3. Template files were much different. Lines that should have existed had been removed, which I assume was done to lessen the load on the server. Fortunately, the template files are generally small, so it’s easy to determine where

Basically, if you are proficient in PHP, you shouldn’t have a lot of problems if you are provided with a change log. If not, you can fake it by getting a file comparison tool, downloading a version of X-Cart that the add-on is actually compatible with, and doing a comparison on the changed files.

After you are done adding the necessary code into the core PHP files and the TPL template files, you can use X-Cart’s built-in patching tool to for any SQL files coupled with your add-on. You can access it in X-Cart version 4.4 by navigating to Tools » Patch/Upgrade and selecting the SQL file(s) in the “Apply SQL Patch” form. It is underneath the “Apply Patch” form.

Be prepared

If you have to go through this process yourself, I have to warn you that it took me several hours to finish. The majority of that time is spent trying to figure out where the code has changed and whether you are looking at the correct instance of the string you are searching for. But, everything worked smoothly after all of the changes were made, so it may be true that X-Cart add-ons made for version 4.3 are generally compatible with version 4.4. The add-on authors are just to lazy to create patch files for the new code.

Did you like this? Share it:
  • http://ksaknhdfui.weebly.com/ Lee Corbet

    oh new version ..

  • http://brandendiaz.webnode.com/ Jelani Barron

    This is made clear by the inability to simply browse products without filtering them, first.

blog comments powered by Disqus