花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來(lái)到素材無(wú)憂網(wǎng),按 + 收藏我們
登錄 注冊(cè) 退出 找回密碼

ecshop商品銷量自定義虛擬銷量已銷售的實(shí)現(xiàn)方法

時(shí)間: 2024-02-25 10:44 閱讀: 作者:素材無(wú)憂網(wǎng)

ecshop商品自定義銷量(虛擬銷量)實(shí)現(xiàn)方法
1.在sq執(zhí)行語(yǔ)句
ALTER TABLE `ecs_goods` ADD `sales_volume_base` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('7','show_goods_sales', 'select', '1,0', '', '1', '1');
INSERT INTO `ecs_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES ('3', 'show_sales_type', 'select', '1,0', '', '1', '1');
注意:如果你的數(shù)據(jù)表前綴不是‘ecs_’ 請(qǐng)自行修改
2./admin/includes/lib_goods.php中
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, " .
" (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
" ORDER BY $filter[sort_by] $filter[sort_order] ".
" LIMIT " . $filter['start'] . ",$filter[page_size]";
修改為
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " .
" (promote_price > 0 AND promote_start_date = '$today') AS is_promote ".
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
" ORDER BY $filter[sort_by] $filter[sort_order] ".
" LIMIT " . $filter['start'] . ",$filter[page_size]";
3./admin/templates/goods_list.htm,在
{if $use_storage} ?{$lang.goods_number}{$sort_goods_number} ?{/if}
后,添加
{$lang.sales_volume_base}{$sort_sales_volume_base}
{if $use_storage} ?{$goods.goods_number} ?{/if}
后,添加
{$goods.sales_volume_base}
4./admin/goods.php,在
/**
* 列表鏈接
* @param ? bool ? ?$is_add 是否添加(插入)
* @param ? string ?$extension_code 虛擬商品擴(kuò)展代碼,實(shí)體商品為空
* @return ?array('href' => $href, 'text' => $text)
*/
function list_link($is_add = true, $extension_code = '')
前,添加
/*------------------------------------------------------ */
//-- 修改商品虛擬銷量
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_sales_volume_base')
{
check_authz_json('goods_manage');
$goods_id = intval($_POST['id']);
$sales_volume_base = json_str_iconv(trim($_POST['val']));
if ($exc->edit("sales_volume_base = '$sales_volume_base', last_update=" .gmtime(), $goods_id))
{
clear_cache_files();
make_json_result(stripslashes($sales_volume_base));
}
}
5.goods.php,在
$smarty->assign('categories', get_categories_tree($goods['cat_id'])); ?// 分類樹(shù)
后,添加
$smarty->assign('sales_count', get_sales_count($goods_id));
在末尾添加
/* 商品累計(jì)銷量帶自定義_新增加 */
function get_sales_count($goods_id)
{
/* 查詢?cè)撋唐返淖远x銷量 */
$sales_base = $GLOBALS['db']->getOne('SELECT sales_volume_base FROM '.$GLOBALS['ecs']->table('goods').' WHERE goods_id = '.$goods_id);
/* 查詢?cè)撋唐返膶?shí)際銷量 */
$sql = 'SELECT IFNULL(SUM(g.goods_number), 0) ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o, ' .
$GLOBALS['ecs']->table('order_goods') . ' AS g ' .
"WHERE o.order_id = g.order_id " .
"AND o.order_status " . db_create_in(array(OS_CONFIRMED, OS_SPLITED)) .
"AND o.shipping_status " . db_create_in(array(SS_SHIPPED, SS_RECEIVED)) .
" AND o.pay_status " . db_create_in(array(PS_PAYED, PS_PAYING)) .
" AND g.goods_id = '$goods_id'";
$sales_count = $GLOBALS['db']->getOne($sql);
/* 商品累計(jì)銷量默認(rèn)顯示方式 */
if ($GLOBALS['_CFG']['show_sales_type'])
{
$row['sales_volume_total'] = ?$sales_count; //實(shí)際銷量 ? ? ?}
else
{
$row['sales_volume_total'] = ?$sales_base + $sales_count; //自定義銷量+實(shí)際銷量 ? ? ?}
return ($row['sales_volume_total']);
}
6.在/languages/zh_cn/admin/shop_config.php,中
/languages/zh_cn/admin/shop_config.php
下,添加
$_LANG['cfg_name']['show_goods_sales'] = '是否顯示商品累計(jì)銷量';
$_LANG['cfg_range']['show_goods_sales']['1'] = '顯示';
$_LANG['cfg_range']['show_goods_sales']['0'] = '不顯示';
$_LANG['cfg_name']['show_sales_type'] = '商品累計(jì)銷量默認(rèn)顯示方式';
$_LANG['cfg_range']['show_sales_type'][1] = '真實(shí)顯示';
$_LANG['cfg_range']['show_sales_type'][0] = '虛擬顯示';
7./languages/zh_cn/admin/goods.php,中
$_LANG['goods_sn_exists'] = '您輸入的貨號(hào)已存在,請(qǐng)換一個(gè)';
后,添加
$_LANG['sales_volume_base'] = '虛擬銷量';
8./languages/zh_cn/common.php,中
$_LANG['divided_into'] = '分成規(guī)則';
后,添加
$_LANG['sales_volume_total'] = '累計(jì)銷量:';
$_LANG['pcs'] = '件';
9./themes/default/goods.dwt,在后,添加
{if $cfg.show_goods_sales}
{$lang.sales_volume_total}
{$sales_count}{if $goods.measure_unit}{$goods.measure_unit}{else}{$lang.pcs}{/if}
{/if}
OK,完成!

版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請(qǐng)注明: ecshop商品銷量自定義虛擬銷量已銷售的實(shí)現(xiàn)方法

標(biāo)簽: ecshop商品銷量  
相關(guān)文章
推薦文章
模板推薦