用户购物车总数新增钩子

This commit is contained in:
gongfuxiang 2022-04-24 17:27:20 +08:00
parent 029c29a4f5
commit e59df0cca4
2 changed files with 21 additions and 7 deletions

View File

@ -81,14 +81,14 @@ class Buy extends Common
// 参数
$params = array_merge($this->data_request, $data);
$params['user'] = $this->user;
$buy_ret = BuyService::BuyTypeGoodsList($params);
$ret = BuyService::BuyTypeGoodsList($params);
// 商品校验
if(isset($buy_ret['code']) && $buy_ret['code'] == 0)
if(isset($ret['code']) && $ret['code'] == 0)
{
// 基础信息
$buy_base = $buy_ret['data']['base'];
$buy_goods = $buy_ret['data']['goods'];
$buy_base = $ret['data']['base'];
$buy_goods = $ret['data']['goods'];
// 用户地址
$address = UserAddressService::UserAddressList(['user'=>$this->user]);
@ -112,7 +112,7 @@ class Buy extends Common
MyViewAssign('is_load_baidu_map_api', 1);
// 钩子
$this->PluginsHook($buy_ret['data'], $params);
$this->PluginsHook($ret['data'], $params);
// 浏览器名称
MyViewAssign('home_seo_site_title', SeoService::BrowserSeoTitle('订单确认', 1));

View File

@ -1687,8 +1687,22 @@ class BuyService
return 0;
}
// 获取购物车总数
$total = self::CartTotal(['user_id'=>$params['user']['id']]);
// 条件
$where = [
['user_id', '=', $params['user']['id']]
];
// 购物车总数读取前钩子
$hook_name = 'plugins_service_user_cart_total_begin';
MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => $params,
'where' => &$where,
]);
$total = self::CartTotal($where);
return ($total > 99) ? '99+' : $total;
}