ecshop设置价格区间不显示

ecshop设置价格区间不显示,第1张

1.

把category.php 里面的

/* 获取价格分级 */

if ($cat['grade'] == 0 &&$cat['parent_id'] != 0)

{

$cat['grade'] = get_parent_grade($cat_id)//如果当前分类级别为空,取最近的上级分类

}

if ($cat['grade'] >1)

{

/* 需要价格分级 */

/*

算法思路:

1、当分级大于1时,进行价格分级

2、取出该类下商品价格的最大值、最小值

3、根据商品价格的最大值来计算商品价格的分级数量级:

价格范围(不含最大值)分级数量级

0-0.1 0.001

0.1-1 0.01

1-100.1

10-100 1

100-100010

1000-10000 100

4、计算价格跨度:

取整((最大值-最小值) / (价格分级数) / 数量级) * 数量级

5、根据价格跨度计算价格范围区间

6、查询数据库

可能存在问题:

1、

由于价格跨度是由最大值、最小值计算出来的

然后再通过价格跨度来确定显示时的价格范围区间

所以可能会存在价格分级数量不正确的问题

该问题没有证明

2、

当价格=最大值时,分级会多出来,已被证明存在

*/

$sql = "SELECT min(g.shop_price) AS min, max(g.shop_price) as max ".

" FROM " . $ecs->table('goods'). " AS g ".

" WHERE ($children OR " . get_extension_goods($children) . ') AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 '

//获得当前分类下商品价格的最大值、最小值

$row = $db->getRow($sql)

// 取得价格分级最小单位级数,比如,千元商品最小以100为级数

$price_grade = 0.0001

for($i=-2$i<= log10($row['max'])$i++)

{

$price_grade *= 10

}

//跨度

$dx = ceil(($row['max'] - $row['min']) / ($cat['grade']) / $price_grade) * $price_grade

if($dx == 0)

{

$dx = $price_grade

}

for($i = 1$row['min'] >$dx * $i$i ++)

for($j = 1$row['min'] >$dx * ($i-1) + $price_grade * $j$j++)

$row['min'] = $dx * ($i-1) + $price_grade * ($j - 1)

for($row['max'] >= $dx * $i$i ++)

$row['max'] = $dx * ($i) + $price_grade * ($j - 1)

$sql = "SELECT (FLOOR((g.shop_price - $row[min]) / $dx)) AS sn, COUNT(*) AS goods_num ".

" FROM " . $ecs->table('goods') . " AS g ".

" WHERE ($children OR " . get_extension_goods($children) . ') AND g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 '.

" GROUP BY sn "

$price_grade = $db->getAll($sql)

foreach ($price_grade as $key=>$val)

{

$price_grade[$key]['start'] = $row['min'] + round($dx * $val['sn'])

$price_grade[$key]['end'] = $row['min'] + round($dx * ($val['sn'] + 1))

$price_grade[$key]['formated_start'] = price_format($price_grade[$key]['start'])

$price_grade[$key]['formated_end'] = price_format($price_grade[$key]['end'])

$price_grade[$key]['url'] = build_uri('category', array('cid'=>$cat_id, 'bid'=>0, 'price_min'=>$price_grade[$key]['start'], 'price_max'=>$price_grade[$key]['end'], 'filter_attr'=>0))

/* 判断价格区间是否被选中 */

if (isset($_REQUEST['price_min']) &&$price_grade[$key]['start'] <= $price_min &&$price_grade[$key]['end'] >= $price_max)

{

$price_grade[$key]['selected'] = 1

}

else

{

$price_grade[$key]['selected'] = 0

}

}

$smarty->assign('price_grade', $price_grade)

}

复制到index.php里面

2.

把price_grade.lbi在index.dwt中找个地方放进去。

3.理论上的研究,没试过

你是说你首页的页面上制作了 一个快速购买按钮 用户可以再哪里直接选择数量 购买 你希望 在用户选择数量在你优惠的区间时 上面的批发价 制动更改为 你设置的 区间价格 是这个意思么 ? 如果是的话 你可以需要 用下 ajax 动态的 去获取价格区间 来比对 用户的数量 以此来修改 价格

ecshop中的几种价格:ecs_goods这个表是用来控制产品信息的表,里面有market_price,shop_price,promote_price和会员等级价格market_price

表示市场价格shop_price

表示本店价格promote_price

表示产品促销价格市场价格可以在后台设置,后台->系统设置->商店设置->商品显示设置->可以选择是否显示"市场价格"打开

themesdefaultgoods.dwt.你可以看到{$lang.market_price}{$goods.market_price}//市场价格{$lang.shop_price}{$goods.shop_price_formated}//本店价格{$rank_price.rank_name}:{$rank_price.price}//会员价格商品总价

{$lang.amount}:

在这里显示,用ajax来控制修改商品总价格的js

如果要删除商品总价,就可以把这两段都删除.会员优惠价格列表.

{$lang.number_to}

优惠价格

{$price_list.number}

{$price_list.format_price}

在goods.dwt中,这段是用来控制优惠价格的。如$volume_price_list不为空,那表面该产品设置了价格等级列表


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11079573.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存