ECSHOP知識線下紅包不能支持最小訂單問題
2024-07-09 22:56:24
供稿:網友
線下紅包都有個bug,就是線下紅包不支持最小訂單,無論多小金額的訂單都能使用紅包。
flow.php文件中找到
/* 驗證紅包序列號 */
elseif ($_REQUEST['step'] == 'validate_bonus')
{
$bonus_sn = trim($_REQUEST['bonus_sn']);
if (is_numeric($bonus_sn))
{
$bonus = bonus_info(0, $bonus_sn);
}
else
{
$bonus = array();
}
// if (empty($bonus) || $bonus['user_id'] > 0 || $bonus['order_id'] > 0)
// {
// die($_LANG['bonus_sn_error']);
// }
// if ($bonus['min_goods_amount'] > cart_amount())
// {
// die(sprintf($_LANG['bonus_min_amount_error'], price_format($bonus['min_goods_amount'], false)));
// }
// die(sprintf($_LANG['bonus_is_ok'], price_format($bonus['type_money'], false)));
$bonus_kill = price_format($bonus['type_money'], false);
include_once('includes/cls_json.php');
$result = array('error' => '', 'content' => '');
/* 取得購物類型 */
$flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
/* 獲得收貨人信息 */
$consignee = get_consignee($_SESSION['user_id']);
/* 對商品信息賦值 */
$cart_goods = cart_goods($flow_type); // 取得商品列表,計算合計
if (empty($cart_goods) || !check_consignee_info($consignee, $flow_type))
{
$result['error'] = $_LANG['no_goods_in_cart'];
}
else
{
/* 取得購物流程設置 */
$smarty->assign('config', $_CFG);
/* 取得訂單信息 */
$order = flow_order_info();
if (((!empty($bonus) && $bonus['user_id'] == $_SESSION['user_id']) || ($bonus['type_money'] > 0 && empty($bonus['user_id']))) && $bonus['order_id'] <= 0)
{
//$order['bonus_kill'] = $bonus['type_money'];
$now = gmtime();
if ($now > $bonus['use_end_date'])
{
$order['bonus_id'] = '';
$result['error']=$_LANG['bonus_use_expire'];
}
else
{
$order['bonus_id'] = $bonus['bonus_id'];
$order['bonus_sn'] = $bonus_sn;
}
}
else
{
//$order['bonus_kill'] = 0;
$order['bonus_id'] = '';
$result['error'] = $_LANG['invalid_bonus'];
}
/* 計算訂單的費用 */
$total = order_fee($order, $cart_goods, $consignee);
$smarty->assign('total', $total);
/* 團購標志 */
if ($flow_type == CART_GROUP_BUY_GOODS)
{
$smarty->assign('is_group_buy', 1);
}
$result['content'] = $smarty->fetch('library/order_total.lbi');
}
$json = new JSON();
die($json->encode($result));
}
修改為
/* 驗證紅包序列號 */
elseif ($_REQUEST['step'] == 'validate_bonus') '商易專業驗證 www.kicshop.com
{
$bonus_sn = trim($_REQUEST['bonus_sn']);
if (is_numeric($bonus_sn))
{
$bonus = bonus_info(0, $bonus_sn);
}
else
{
$bonus = array();
}
$bonus_kill = price_format($bonus['type_money'], false); '成都商易
include_once('includes/cls_json.php');
$result = array('error' => '', 'content' => '');
/* 取得購物類型 */
$flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
/* 獲得收貨人信息 */
$consignee = get_consignee($_SESSION['user_id']);
/* 對商品信息賦值 */
$cart_goods = cart_goods($flow_type); // 取得商品列表,計算合計
if (empty($cart_goods) || !check_consignee_info($consignee, $flow_type))
{
$result['error'] = $_LANG['no_goods_in_cart'];
}
else
{
/* 取得購物流程設置 */
$smarty->assign('config', $_CFG);
/* 取得訂單信息 */
$order = flow_order_info();
if ($bonus['min_goods_amount'] <= cart_amount())
{
if (((!empty($bonus) && $bonus['user_id'] == $_SESSION['user_id']) || ($bonus['type_money'] > 0 && empty($bonus['user_id']))) && $bonus['order_id'] <= 0)
{
//$order['bonus_kill'] = $bonus['type_money'];
$now = gmtime();
if ($now > $bonus['use_end_date'])
{
$order['bonus_id'] = '';
$result['error']=$_LANG['bonus_use_expire'];
}
else
{
$order['bonus_id'] = $bonus['bonus_id'];
$order['bonus_sn'] = $bonus_sn;
}
}
else
{
//$order['bonus_kill'] = 0;
$order['bonus_id'] = '';
$result['error'] = $_LANG['invalid_bonus'];
}
}
else
{
$result['error'] = sprintf($_LANG['bonus_min_amount_error'], price_format($bonus['min_goods_amount'], false));
}
/* 計算訂單的費用 */
$total = order_fee($order, $cart_goods, $consignee);
$smarty->assign('total', $total);
/* 團購標志 */
if ($flow_type == CART_GROUP_BUY_GOODS)
{
$smarty->assign('is_group_buy', 1);
}
$result['content'] = $smarty->fetch('library/order_total.lbi');
}
$json = new JSON();
die($json->encode($result));