您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop不同商品设置不同快递运费商品页显示快递运费的实现方法
含玉2024-01-21 00:40:00ecshop商城教程已有人查阅
导读ECSHOP商品页面显示快递运费,同时商品可以设置指定快递,不同商品不同运费二次开发教程。 先看看效果图: ‘安装和设置流程如下:一.ecshop后台系统
ECSHOP商品页面显示快递运费,同时商品可以设置指定快递,不同商品不同运费二次开发教程。
安装和设置流程如下:
一、ecshop后台系统设置----配送方式---选择你要的快递点击安装,同时设置不同地区运费
二、商品绑定配送方式的运费模板
在ecshop后台:数据库管理--sql查询执行下面SQL语句: 注意你如果数据表不是ecs请修改在执行ecs_
ALTER TABLE `ecs_goods` ADD `shipping_id` MEDIUMINT(9) NOT NULL DEFAULT '8';
如何查看快递ID? 可以鼠标自动到设置区域,在浏览器左下角就会显示当前快递ID
三,找到admin/goods.php 尾部增加
重写“include/lib_order.php”中last_shipping_and_payment函数。多个商品,不同配送方式,调用配送方式ID,以最贵配送方式计算。买家可以找客服进行,运费改价。
安装和设置流程如下:
一、ecshop后台系统设置----配送方式---选择你要的快递点击安装,同时设置不同地区运费
二、商品绑定配送方式的运费模板
在ecshop后台:数据库管理--sql查询执行下面SQL语句: 注意你如果数据表不是ecs请修改在执行ecs_
ALTER TABLE `ecs_goods` ADD `shipping_id` MEDIUMINT(9) NOT NULL DEFAULT '8';
如何查看快递ID? 可以鼠标自动到设置区域,在浏览器左下角就会显示当前快递ID
三,找到admin/goods.php 尾部增加
/**
* 取得已安装的配送方式-ecshop119运费
* @return array 已安装的配送方式
*/
function shipping_list()
{
$sql = 'SELECT shipping_id, shipping_name ' .
'FROM ' . $GLOBALS['ecs']->table('shipping') .
' WHERE enabled = 1';
return $GLOBALS['db']->getAll($sql);
}
继续找到:$smarty->assign('unit_list', get_unit_list());在他前面增加
$smarty->assign('shipping_list', shipping_list());//LONGHTML增加运费模板
继续:找到/* 处理商品数据 */ 最后面增加下面这句
// 运费模板(新增,更新)
$shipping_id = empty($_POST['shipping_id']) ? '0' : intval($_POST['shipping_id']);
// END
找到 /* 入库 */
中间省略
/* 如果有上传图片,需要更新数据库 */
其中这段替换成下面这句话
/* 入库 ecshop119运费这段替换*/
/* 入库 *//* 更新下面入库shipping_id "shipping_id = '$shipping_id', " .*/
/* 入库 */
if ($is_insert)
{
if ($code == '')
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id ,shipping_id)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id' , '$shipping_id')";
}
else
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral,shipping_id)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral', '$shipping_id')";
}
}
else
{
/* 如果有上传图片,删除原来的商品图 */
$sql = "SELECT goods_thumb, goods_img, original_img " .
" FROM " . $ecs->table('goods') .
" WHERE goods_id = '$_REQUEST[goods_id]'";
$row = $db->getRow($sql);
if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
{
@unlink(ROOT_PATH . $row['goods_img']);
@unlink(ROOT_PATH . $row['original_img']);
}
if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
{
@unlink(ROOT_PATH . $row['goods_thumb']);
}
$sql = "UPDATE " . $ecs->table('goods') . " SET " .
"goods_name = '$_POST[goods_name]', " .
"goods_name_style = '$goods_name_style', " .
"goods_sn = '$goods_sn', " .
"cat_id = '$catgory_id', " .
"brand_id = '$brand_id', " .
"shop_price = '$shop_price', " .
"market_price = '$market_price', " .
"is_promote = '$is_promote', " .
"promote_price = '$promote_price', " .
"promote_start_date = '$promote_start_date', " .
"suppliers_id = '$suppliers_id', " .
"shipping_id = '$shipping_id', " .
"promote_end_date = '$promote_end_date', ";
/* 如果有上传图片,需要更新数据库 */
/* 更新下面入库shipping_id "shipping_id = '$shipping_id', " .结束*/
/* 如果有上传图片,需要更新数据库 */
/* 如果有上传图片,需要更新数据库 ecshop119运费这段替换结
四,找到admin/goods_info.htm找到
{if $suppliers_exists eq 1}
在他上面增加:
<tr>
<td class="label">运费模板</td>
<td><select name="shipping_id" ><option value="0">{$lang.select_please}
{foreach from=$shipping_list item=shipping}
<option value="{$shipping.shipping_id}" {if $shipping.shipping_id eq $goods.shipping_id}selected{/if}>{$shipping.shipping_name}</option> {/foreach}
</select>{$lang.require_field}</td>
</tr>
五,找到根目录:goods.php文件 找到 if ($goods['brand_id'] > 0) 在他上面增加
/* ***** ecshop119运费商品页按地区显示运费 ***********************************************************************/
/***** 商品页按地区显示运费 ***********************************************************************/
$shippings = array();
$res = $db->GetAll("SELECT shipping_name, shipping_id FROM ecs_shipping WHERE shipping_id=".$goods['shipping_id']);
//$res = $db->GetAll("SELECT shipping_name, shipping_id FROM ecs_shipping");
foreach ($res as $value)
{
$areas = array();
$res1 = $db->GetAll("SELECT * FROM ecs_shipping_area WHERE shipping_id = $value[shipping_id]");
foreach ($res1 as $area)
{
$configure = unserialize($area['configure']);
if (is_array($configure))
{
foreach ($configure as $c)
{
if ($c['name'] == 'base_fee')
{
$price = $c['value'];
}
}
}
$sql = "SELECT a.region_id, r.region_name ".
"FROM ".$ecs->table('area_region')." AS a, ".$ecs->table('region'). " AS r ".
"WHERE r.region_id=a.region_id AND a.shipping_area_id='$area[shipping_area_id]'";
$res2 = $db->query($sql);
while ($arr = $db->fetchRow($res2))
{
$value['areas'][$arr['region_name']] = $price;
}
}
$shippings[] = $value;
}
$res = $db->GetAll("SELECT region_id,region_name FROM ecs_region WHERE parent_id = 1");
if($goods['shipping_id'] == 8)//默认显示8快递ID
{
$current_region = '福建'; //默认显示福建
$smarty->assign('current_region', $current_region);
$smarty->assign('current_price', '15');//默认显示福建到福建省8元请写快递一致的价格
}
foreach ($res as $value)
{
$row = array();
foreach ($shippings as $a => $shipping)
{
if ($shipping['areas'])
{
foreach ($shipping['areas'] as $key => $price)
{
if ($key == $value['region_name'])
{
$row[$a]['shipping_price'] = $price;
}
}
}
if ($row[$a]['shipping_price'] > 0)
{
$row[$a]['shipping_name'] = $shipping['shipping_name'];
$value['shippings'] = $row;
}
}
if ($value['shippings']) $regions[] = $value;
}
$smarty->assign('regions',$regions);
/****************************************************************************/
/****************************运费结束****************************************/
六,goods.dwt 加在需要显示运费的地方,根据自己需要调整。
<li class="clearfix">
<dd>
<!--{if $regions}-->
<script src="themes/default/js/chrome.js" type="text/javascript"></script>
{foreach from=$regions key=key item=value}
{if $key == 0}
<p id="chromemenu">配送至 <a rel="dropmenu1" href="javascript:;"><b id="s_a_name">{$current_region}</b><img style="margin:0 2px 0 2px;" src="images/icon_2.jpg" align="absmiddle" /></a>:<b id="s_a_price">
{foreach from=$value.shippings item=shipping}
{$shipping.shipping_name}{$current_price}元
{/foreach}
</b>
</p>
{/if}
{/foreach}
<div id="dropmenu1" class="dropmenudiv">
{foreach from=$regions item=value}
<a href="javascript:;" onclick="show_shipping('{$value.region_name}','{foreach from=$value.shippings item=shipping}{$shipping.shipping_name}{$shipping.shipping_price}元 {/foreach}')">{$value.region_name}</a>
{/foreach}
</div>
<script>
function show_shipping(name,price)
{
document.getElementById("s_a_name").innerHTML = name;
document.getElementById("s_a_price").innerHTML = price;
}
cssdropdown.startchrome("chromemenu");
</script>
<style>
#chromemenu b { font-weight:normal}
.dropmenudiv {position:absolute;top: 0;z-index:100;width:200px;visibility: hidden; background:#fdffee; padding:8px; border:solid #ffbf69 2px; line-height:25px;}
.dropmenudiv a { margin:0 5px 0 5px;}
</style>
<!--{/if}-->
</dd>
</li>
七,结算流程中,根据配送地址计算运费重写“include/lib_order.php”中last_shipping_and_payment函数。多个商品,不同配送方式,调用配送方式ID,以最贵配送方式计算。买家可以找客服进行,运费改价。
/**
* 获得上一次用户采用的支付和配送方式
*
* @access public
* @return void
*/
function last_shipping_and_payment()
{
$sql = "SELECT shipping_id, pay_id " .
" FROM " . $GLOBALS['ecs']->table('order_info') .
" WHERE user_id = '$_SESSION[user_id]' " .
" ORDER BY order_id DESC LIMIT 1";
$row = $GLOBALS['db']->getRow($sql);
/* LONGHTML 获得购物车中商品 运费模板很大值 */
$sql = "SELECT DISTINCT max(g.shipping_id) as shipping_id " .
" FROM " . $GLOBALS['ecs']->table('cart') ." AS c ".
" LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON c.goods_id = g.goods_id" .
" WHERE c.`session_id` = '" . SESS_ID . "'".
" AND c.`extension_code` != 'package_buy' ";
$shipping_id = $GLOBALS['db']->getOne($sql);
$row['shipping_id'] = $shipping_id;
// END
if (empty($row))
{
/* 如果获得是一个空数组,则返回默认值 */
$row = array('shipping_id' => 0, 'pay_id' => 0);
}
return $row;
}
flow.php购物流程checkout,done步骤,调用商品绑定的配送方式
/* 对是否允许修改购物车赋值 */
if ($flow_type != CART_GENERAL_GOODS || $_CFG['one_step_buy'] == '1')
{
$smarty->assign('allow_edit_cart', 0);
}
else
{
$smarty->assign('allow_edit_cart', 1);
}
// LONGHTML 很大值的运费模板
$arr = last_shipping_and_payment();
$_SESSION['flow_order']['shipping_id'] = $arr['shipping_id'];
$smarty->assign('select_shipping_id', $arr['shipping_id']);
// END
将themes/default/flow.dwt配送方式隐藏掉
<!--{if $total.real_goods_count neq 0}-->
<div class="" style="display:none;">
<h5><span>{$lang.shipping_method}</span></h5>
<table width="984" align="center" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd" id="shippingTable">
<tr align="center">
<th align="center" bgcolor="#ffffff" width="5%"> </th>
<th align="center" bgcolor="#ffffff" width="25%">{$lang.name}</th>
<th align="center" bgcolor="#ffffff">{$lang.describe}</th>
<th align="center" bgcolor="#ffffff" width="15%">{$lang.fee}</th>
<th align="center" bgcolor="#ffffff" width="15%">{$lang.free_money}</th>
<th align="center" bgcolor="#ffffff" width="15%">{$lang.insure_fee}</th>
</tr>
<!-- {foreach from=$shipping_list item=shipping} 循环配送方式 -->
<tr align="center">
<td align="center" bgcolor="#ffffff" valign="top"><input name="shipping" id="shipping_se" type="radio" value="{$shipping.shipping_id}" {if ($order.shipping_id eq $shipping.shipping_id) or true}checked="true"{/if} supportCod="{$shipping.support_cod}" insure="{$shipping.insure}" onclick="selectShipping(this)" />
</td>
<td align="center" bgcolor="#ffffff" valign="top"><strong>{$shipping.shipping_name}</strong></td>
<td align="center" bgcolor="#ffffff" valign="top">{$shipping.shipping_desc}</td>
<td bgcolor="#ffffff" align="center" valign="top">{$shipping.format_shipping_fee}</td>
<td bgcolor="#ffffff" align="center" valign="top">{$shipping.free_money}</td>
<td bgcolor="#ffffff" align="center" valign="top">{if $shipping.insure neq 0}{$shipping.insure_formated}{else}{$lang.not_support_insure}{/if}</td>
</tr>
<!-- {/foreach} 循环配送方式 -->
<!-- LONGHTML --><script>selectShipping02({$select_shipping_id});</script> <!-- END -->
<tr align="center">
<td colspan="6" bgcolor="#ffffff" align="center"><label for="ECS_NEEDINSURE">
<input name="need_insure" id="ECS_NEEDINSURE" type="checkbox" onclick="selectInsure(this.checked)" value="1" {if $order.need_insure}checked="true"{/if} {if $insure_disabled}disabled="true"{/if} />
{$lang.need_insure} </label></td>
</tr>
</table>
</div>
<div class="blank"></div>
<!--{else}-->
<input name = "shipping" type="radio" value = "-1" checked="checked" style="display:none"/>
<!--{/if}-->
本文标签:
很赞哦! ()
相关文章
- ecshop快递打印物流电子面单打印方法
- ecshop文章附件文件限制指定会员等级的会员才能下载
- ecshop商品列表页面和商品页面自定义url网址前缀的实现方法
- ecshop订单总价币种汇率转换介绍
- ecshop商城首页增加一个商品浏览排行榜的实现方法
- ecshop文章日期文章时间修改和添加文章时间日期选择方法
- ecshop数据库清空的方法,ecshop数据执行SQL命令收集整理
- ecshop商品页显示商品收藏数量怎么修改
- ecshop商店设置中商店公告任意调用显示在任何页面的方法
- ecshop会员登陆后可见价格,ecshop会员登陆后显示价格实例
- ecshop商城怎么增加新独立页面
- ecshop后台添加补货卡密去掉重复添加卡密限制的示例
随机图文
-
ecshop首页主广告管理使用说明
ECSHOP首页主广告管理,ECSHOP首页广告位。在网店后台 -> 系统设置 -> 首页主广告管理,可以设置首页主广告位。 -
ecshop商品批量导出数据包制作导出的方法
今天为大家详细解说一下ECSHOP商品批量导出,ECSHOP商品数据包制作导出设置。搜索到的商品会显示在左边的框内,选中后,点击右箭头按钮会添加到右侧的框内 -
ecshop导出会员,ecshop会员批量导出邮箱教程
ECSHOP批量导出会员邮箱_ECSHOP会员批量导出邮箱修改教程 一、编辑/admin/users.php,添加代码/*---------------- -
ecshop留言板里怎么添加1项必填项表单
ecshop留言板添加一项必填项-联系人 一、首先要为你的数据库的ecs_comment增加一个字段以存储联系人姓名: 可以直接在后台--数据库管理---SQL查询里里直接执行
留言与评论 (共有 条评论) |