简介
X-Cart是一款PHP购物车软件,旨在简化网上购物者的生活。他们只需选择必要的物品,将其添加到购物车中,即可获得最终付款(包括运费和税款)。在线商家将X-Cart添加到他们的商店,因为:
- 这是一个PHP购物车程序,成本不高。
- X-Cart与PCI-DSS 100%兼容。
- 它附带了几个专业的电子商务设计模板。
- 它对搜索引擎很友好。
如果您想加快在线商店的速度,请将CDN与X-Cart平台集成。阅读下面的详细说明。
准备工作
由于我们接下来将使用Cname地址,请确保您已在控制台上配置了CDN资源。
如果您想在https://页面上集成CDN服务,您必须确保在控制台上启用了SSL。
如果您的网站嵌入了自定义字体,请确认您已在LightCDN控制台中启用CORS标头。
集成方法
在X-cart启用CDN
打开X-Cart根目录中的文件smarty.php。
更换以下路径。
$smarty->assign('ImagesDir', $xcart_web_dir . $smarty_skin_dir . '/images');
$smarty->assign('SkinDir', $xcart_web_dir . $smarty_skin_dir);
更换成下面几行。
$smarty->assign('ImagesDir', 'http://12345.r.cdn36.net' . $smarty_skin_dir . '/images');
$smarty->assign('SkinDir', 'http://12345.r.cdn36.net' . $smarty_skin_dir);
打开 /include/templater/plugins/function.load_defer_code.php。
更换以下路径。
$cacheWebFile = $var_dirs_web['cache'] . '/' . $label . '.' . $md5Suffix . '.' . $type;
更换成下面几行。
$cacheWebFile = 'http://12345.r.cdn36.net' . $var_dirs_web['cache'] . '/' . $label . '.' . $md5Suffix . '.' . $type;
打开 /include/func/func.files.php。
查找(而不是替换)以下行。
global $config, $sql_tbl, $xcart_dir, $current_location;
并添加(而不是替换)以下行。
$current_location = 'http://12345.r.cdn36.net';
打开文件 /include/templater/plugins/function.get_category_image_url.php。
更换以下路径。
return func_convert_amp(func_get_image_url($category['categoryid'], 'C', $category['image_path']));
下面一行,www.examplecom应该是您网站的域名。
return str_replace('www.example.com', '12345.r.cdn36.net', func_convert_amp(func_get_image_url($category['categoryid'], 'C', $category['image_path'])));
打开文件 /skin/common_files/modules/Banner_System/banner_rotator.tpl。
更换以下路径。
src="{$content.image_path|amp}"
下面一行,www.example.com应该是您网站的域名。
src="{$content.image_path|amp|replace:'www.example.com':'12345.r.cdn36.net'}"