在ecshop官方模版手机端的虚拟商品购买后不能像pc端那般直接在付款后出现虚拟商品的卡号,密码,截止日期,好模板提供的解决方法如下: if ($order['bonus_id'] > 0 && $temp_amout > 0) { use_bonus($order['bonus_id'], $new_order_id); } 下面还有两端代码是手机端没有的 /* 给商家发邮件 ----- 这段或许可以不要,我没有测试 */ /* 增加是否给客服发送邮件选项 */ if ($_CFG['send_service_email'] && $_CFG['service_email'] != '') { $tpl = get_mail_template('remind_of_new_order'); $smarty->assign('order', $order); $smarty->assign('goods_list', $cart_goods); $smarty->assign('shop_name', $_CFG['shop_name']); $smarty->assign('send_date', date($_CFG['time_format'])); $content = $smarty->fetch('str:' . $tpl['template_content']); send_mail($_CFG['shop_name'], $_CFG['service_email'], $tpl['template_subject'], $content, $tpl['is_html']); } /* 如果需要,发短信 ----- 这段也是没有的,应该也不需要*/ if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '') { include_once('includes/cls_sms.php'); $sms = new sms(); $msg = $order['pay_status'] == PS_UNPAYED ? $_LANG['order_placed_sms'] : $_LANG['order_placed_sms'] . '[' . $_LANG['sms_paid'] . ']'; $sms->send($_CFG['sms_shop_mobile'], sprintf($msg, $order['consignee'], $order['tel']),'', 13,1); }
下面的关键的代码 ----- 是关系到我们现在的功能是不是能用 /* 如果订单金额为0 处理虚拟卡 */ if ($order['order_amount'] <= 0) { $sql = "SELECT goods_id, goods_name, goods_number AS num FROM ". $GLOBALS['ecs']->table('cart') . " WHERE is_real = 0 AND extension_code = 'virtual_card'". " AND session_id = '".SESS_ID."' AND rec_type = '$flow_type'"; $res = $GLOBALS['db']->getAll($sql); $virtual_goods = array(); foreach ($res AS $row) { $virtual_goods['virtual_card'][] = array('goods_id' => $row['goods_id'], 'goods_name' => $row['goods_name'], 'num' => $row['num']); } if ($virtual_goods AND $flow_type != CART_GROUP_BUY_GOODS) { /* 虚拟卡发货 */ if (virtual_goods_ship($virtual_goods,$msg, $order['order_sn'], true)) { /* 如果没有实体商品,修改发货状态,送积分和红包 */ $sql = "SELECT COUNT(*)" . " FROM " . $ecs->table('order_goods') . " WHERE order_id = '$order[order_id]' " . " AND is_real = 1"; if ($db->getOne($sql) <= 0) { /* 修改订单状态 */ update_order($order['order_id'], array('shipping_status' => SS_SHIPPED, 'shipping_time' => gmtime())); /* 如果订单用户不为空,计算积分,并发给用户;发红包 */ if ($order['user_id'] > 0) { /* 取得用户信息 */ $user = user_info($order['user_id']); /* 计算并发放积分 */ $integral = integral_to_give($order); log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($_LANG['order_gift_integral'], $order['order_sn'])); /* 发放红包 */ send_order_bonus($order['order_id']); } } } } } 这里的代码添加上以后变量已经发送到页面中了,在手机模版收是order_done.dwt文件来显示最后一步的,这里和pc端的flow.dwt里全是判断的思路不太一样,找到flow.dwt文件中显示虚拟商品信息的那段代码如下(其实可以自己找找) <!--{if $virtual_card}--> <div style="text-align:center;overflow:hidden;border:1px solid #E2C822;background:#FFF9D7;margin:10px;padding:10px 50px 30px;"> <!--{foreach from=$virtual_card item=vgoods}--> <h3 style="color:#2359B1; font-size:12px;">{$vgoods.goods_name}</h3> <!--{foreach from=$vgoods.info item=card}--> <ul style="list-style:none;padding:0;margin:0;clear:both"> <!--{if $card.card_sn}--> <li style="margin-right:50px;float:left;"> <strong>卡号:</strong><span style="color:red;">{$card.card_sn}</span> </li> <!--{/if}--> <!--{if $card.card_password}--> <li style="margin-right:50px;float:left;"> <strong>密码:</strong><span style="color:red;">{$card.card_password}</span> </li> <!--{/if}--> <!--{if $card.end_date}--> <li style="float:left;"> <strong>截止日期:</strong>{$card.end_date} </li> <!--{/if}--> </ul> <!--{/foreach}--> <!--{/foreach}--> </div> <!--{/if}-->
放到order_done.dwt里一个合适的位置,到此这个功能大概就完成了 |