ecshop如何設定了購買停留在商品頁面之後。將ecshop商品加入購物車的時候。就不會直接進入購物車。這樣使用購物車非常不方便。我們為了既保持該頁面功能,又能進入購物車功能。所以增加了另外乙個購買按扭。點購買之後。可以直接進入ecshop的購物車。這樣只牽涉到修改ecshop模板,對ecshop二次開發稍微修改就可以做到。
1:goods.dwt模板
2:js/common.js
function addtocart1(goodsid, parentid)
var goods = new object();
var spec_arr = new array();
var fittings_arr = new array();
var number = 1;
var formbuy = document.forms['ecs_formbuy'];
var quick = 0;
// 檢查是否有商品規格
if (formbuy)
spec_arr = getselectedattributes(formbuy);
if (formbuy.elements['number'])
number = formbuy.elements['number'].value;
quick = 1;
goods.quick = quick;
goods.spec = spec_arr;
goods.goods_id = goodsid;
goods.number = number;
goods.parent = (typeof(parentid) == "undefined") ? 0 : parseint(parentid);
ajax.call('flow.php?step=add_to_cart1', 'goods=' + goods.tojsonstring(), addtocartresponse1, 'post', 'json');
function addtocartresponse1(result)
if (result.error > 0)
// 如果需要缺貨登記,跳轉
if (result.error == 2)
if (confirm(result.message))
location.href = 'user.php?act=add_booking&id=' + result.goods_id + '&spec=' + result.product_spec;
// 沒選規格,彈出屬性選擇框
else if (result.error == 6)
openspediv(result.message, result.goods_id, result.parent);
else
alert(result.message);
else
var cartinfo = document.getelementbyid('ecs_cartinfo');
var cart_url = 'flow.php?step=cart';
if (cartinfo)
cartinfo.innerhtml = result.content;
location.href = cart_url;
3:flow.php
elseif ($_request['step'] == 'add_to_cart1')
include_once('includes/cls_json.php');
$_post['goods'] = json_str_iconv($_post['goods']);
if (!empty($_request['goods_id']) && empty($_post['goods']))
if (!is_numeric($_request['goods_id']) || intval($_request['goods_id']) <= 0)
ecs_header("location:./\n");
$goods_id = intval($_request['goods_id']);
exit;
$result = array('error' => 0, 'message' => '', 'content' => '', 'goods_id' => '');
$json = new json;
if (empty($_post['goods']))
$result['error'] = 1;
die($json->encode($result));
$goods = $json->decode($_post['goods']);
/* 檢查:如果商品有規格,而post的資料沒有規格,把商品的規格屬性通過json傳到前台 */
if (empty($goods->spec) and empty($goods->quick))
$sql = "select a.attr_id, a.attr_name, a.attr_type, ".
"g.goods_attr_id, g.attr_value, g.attr_price " .
'from ' . $globals['ecs']->table('goods_attr') . ' as g ' .
'left join ' . $globals['ecs']->table('attribute') . ' as a on a.attr_id = g.attr_id ' .
"where a.attr_type != 0 and g.goods_id = '" . $goods->goods_id . "' " .
'order by a.sort_order, g.attr_price, g.goods_attr_id';
$res = $globals['db']->getall($sql);
if (!empty($res))
$spe_arr = array();
foreach ($res as $row)
$spe_arr[$row['attr_id']]['attr_type'] = $row['attr_type'];
$spe_arr[$row['attr_id']]['name'] = $row['attr_name'];
$spe_arr[$row['attr_id']]['attr_id'] = $row['attr_id'];
$spe_arr[$row['attr_id']]['values'] = array(
'label' => $row['attr_value'],
'price' => $row['attr_price'],
'format_price' => price_format($row['attr_price'], false),
'id' => $row['goods_attr_id']);
$i = 0;
$spe_array = array();
foreach ($spe_arr as $row)
$spe_array=$row;
$result['error'] = err_need_select_attr;
$result['goods_id'] = $goods->goods_id;
$result['parent'] = $goods->parent;
$result['message'] = $spe_array;
die($json->encode($result));
/* 檢查:商品數量是否合法 */
if (!is_numeric($goods->number) || intval($goods->number) <= 0)
$result['error'] = 1;
$result['message'] = $_lang['invalid_number'];
/* 更新:購物車 */
else
// 更新:新增到購物車
if (addto_cart($goods->goods_id, $goods->number, $goods->spec, $goods->parent))
if ($_cfg['cart_confirm'] > 2)
$result['message'] = '';
else
$result['message'] = $_cfg['cart_confirm'] == 1 ? $_lang['addto_cart_success_1'] : $_lang['addto_cart_success_2'];
$result['content'] = insert_cart_info();
$result['one_step_buy'] = $_cfg['one_step_buy'];
else
$result['message'] = $err->last_message();
$result['error'] = $err->error_no;
$result['goods_id'] = stripslashes($goods->goods_id);
if (is_array($goods->spec))
$result['product_spec'] = implode(',', $goods->spec);
else
$result['product_spec'] = $goods->spec;
$result['confirm_type'] =3;
die($json->encode($result));
給UIImageView增加點選事件
自己做了乙個九宮格,裡面的圖示都是由多張重疊構成,然後包裝成乙個button來使用 遇到的問題是如何給這個 button 增加點選事件?解決思路1 提示在該 button 上增加乙個真正的透明button,這樣就可以順利執行點選事件了 但是本人嘗試發現,如果我調整了button的透明度後,點選是沒有...
ISO給UIImageView增加點選事件
自己做了乙個九宮格,裡面的圖示都是由多張重疊構成,然後包裝成乙個button來使用 遇到的問題是如何給這個 button 增加點選事件?解決思路1 提示在該 button 上增加乙個真正的透明button,這樣就可以順利執行點選事件了 但是本人嘗試發現,如果我調整了button的透明度後,點選是沒有...
給UIImageView新增點選事件
uiimageview imageview1 uiimageview alloc initwithframe cgrectmake 125,50,229,229 imageview1 setimage uiimage imagewithcontentsoffile path imageview1.u...