You are viewing the legacy StackPath SecureCDN Help Center. Please use support.stackpath.com if you signed up after July 1, 2018 or log in through control.stackpath.com

StackPath Support

X-Cart: StackPath CDN Setup Guide

According to X-Cart's help wiki: "Setting up a CDN for your medium to large X-Cart site will help improve its loading times across the world by delivering static content from the [StackPath] server located closest to your customer."

In each section of this tutorial, swap site.company.stackpathdns.com in the code with your CDN URL and yourdomain.com with your actual domain name. Also, replace ideal_comfort in the code with the name of your skin if you're not using the Ideal Comfort skin.

This tutorial assumes a site is created and is for X-Cart 4.4 and later.

Fixed Skin Path

  1. Open the core X-Cart file called smarty.php.

    It's located in root directory of X-Cart.

  2. Find these two lines:

    ​$smarty->assign('ImagesDir',        $xcart_web_dir . $smarty_skin_dir . '/images');
            $smarty->assign('SkinDir',          $xcart_web_dir . $smarty_skin_dir); 
  3. Replace them with this code:

    // WCM - StackPath Integration
            if ($_SERVER['HTTPS'] != 'on')
            {
            $smarty->assign("SkinDir","http://site.company.stackpathdns.com/skin/ideal_comfort");
            $smarty->assign("ImagesDir","http://site.company.stackpathdns.com/skin/ideal_comfort/images");
            }
            else
            {
            $smarty->assign("SkinDir",$xcart_web_dir."/skin/ideal_comfort");
            $smarty->assign("ImagesDir",$xcart_web_dir."/skin/ideal_comfort/images");
            }
  4. Verify StackPath is properly integrated.

Dynamic Skin Path

If you want your skin path assigned dynamically, follow the steps in this section.

  1. Open the core X-Cart file called smarty.php.

    It's located in root directory of X-Cart.

  2. Find these two lines:

    ​$smarty->assign('ImagesDir',        $xcart_web_dir . $smarty_skin_dir . '/images');
            $smarty->assign('SkinDir',          $xcart_web_dir . $smarty_skin_dir); 
  3. Replace them with this code:

    // WCM - MaxCDN Implementation
                    if ($_SERVER['HTTPS'] != 'on')
                    {
                    $smarty->assign('ImagesDir',        "http://site.company.stackpathdns.com" . $smarty_skin_dir . '/images');
                    $smarty->assign('SkinDir',          "http://site.company.stackpathdns.com" . $smarty_skin_dir);
                    }
                    else
                    {
                    $smarty->assign('ImagesDir',        $xcart_web_dir . $smarty_skin_dir . '/images');
                    $smarty->assign('SkinDir',          $xcart_web_dir . $smarty_skin_dir);
                    }
  4. Open /include/templater/plugins/function.load_defer_code.php and find this line:

    $cacheWebFile = $var_dirs_web['cache'] . '/' . $label . '.' . $md5Suffix . '.' . $type;
  5. Replace it with this code:

    if ($_SERVER['HTTPS'] != 'on') 
                    { 
                    $cacheWebFile = "http://site.company.stackpathdns.com/var/cache" . '/' . $label . '.' . $md5Suffix . '.' . $type; 
                    } 
                    else 
                    { 
                    $cacheWebFile = $var_dirs_web['cache'] . '/' . $label . '.' . $md5Suffix . '.' . $type; 
                    }
  6. Open /include/func/func.files.php and find this line:

    ​global $config, $sql_tbl, $xcart_dir, $current_location;
  7. Add this new code below it. (DO NOT replace.)
    ​if ($HTTPS) 
                    $current_location = $current_location; 
                    else 
                    $current_location = 'http://site.company.stackpathdns.com';
  8. Open /include/templater/plugins/function.get_category_image_url.php and find this line:

    return func_convert_amp(func_get_image_url($category['categoryid'], 'C', $category['image_path']));
  9. Replace it with this code:

    return return str_replace("domain.com ","site.company.stackpathdns.com",func_convert_amp(func_get_image_url($category['categoryid'], 'C', $category['image_path'])));
  10. Open /skin/common_files/modules/Banner_System/banner_rotator.tpl and find this line:
    src="{$content.image_path|amp}"
  11. Replace it with this code:

    src="{$content.image_path|amp|replace:'domain.com':'site.company.stackpathdns.com'}"
  12. Verify StackPath is properly integrated.
Return to top