超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測評推薦
專注分享VPS主機優惠信息
衡天云優惠活動
熱網互聯2026年促銷活動
hostkvm優惠促銷活動
zji優惠促銷活動
QQGNET優惠促銷活動
QQGNET優惠促銷活動

帝國ECMS如何實現無需刷新即可加入購物車的AJAX(帝國CMS用戶手冊)

主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情!
我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

帝國ECMS如何實現無需刷新即可加入購物車的AJAX(帝國CMS用戶手冊)

帝國ecms如何實現ajax而不刷新加入購物車

帝國ECMS在不刷新的情況下將AJAX添加到購物車的主要步驟如下:

a、修改商城內容模板,在頭部添加以下代碼:

& lt腳本類型= & quot文本/JavaScript & quot;src = & quot[!--news . URL --】skin/default/js/jquery . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;src = & quot[!--news . URL --】skin/default/js/addbuycar . js & quot;& gt& lt/script & gt;& lt腳本類型= & quot文本/JavaScript & quot;& gtvar newsurl=&amp。#39;& lt?= $ public _ r【news URL】?& gt& amp#39;;& lt/script & gt;第二,修改商城的內容模板,并添加購物車將其修改為以下代碼:

& lta href = & quot# ecms & quotonclick = & quotAddProduct(【!--classid--】,【!--id--】);"& gt加入購物車

函數add product(classid,id){ $。Ajax({ type:& quot;帖子& quot網址:news URL+& quot;e/template/ShopSys/add buy car . PHP & quot;數據:& quotclassid = & quot+classid+& quot;& ampid = & quot+ id,數據類型:json & quot,成功:function(JSON){ alert(JSON . msg);}}}第四,添加處理程序e/template/shopsys/addbuycar . PHP,其源代碼如下:

& lt?php要求(& quot../../class/connect . PHP & quot;);要求(& quot../../class/db _ SQL . PHP & quot;);要求(& quot../../data/dbcache/class.php&quot);要求(& quot../../class/shopsysfun . PHP & quot;);$ link = db _ connect();$ empire = new MySQL query();& lt/p & gt;& ltp & gt//$ _ POST $ classid =(int)$ _ POST【& amp;#39;classid & amp#39;];$ id =(int)$ _ POST【& amp;#39;id & amp#39;];& lt/p & gt;& ltp & gt//添加函數function JSON _ AddBuycar($ classid,$ id){ global $ class _ r,$empire,$dbtbpre,$ public _ r;$ classid =(int)$ classid;$ id =(int)$ id;if(empty($ classid)| | empty($ class _ r【$ classid】【TB name】){ return JSON _ encode(array(& amp;#39;msgid & amp#39;= & gt1 & amp;#39;味精& amp#39;= & gt& amp#39;此產品不存在&;#39;));}//驗證產品是否具有$ num = $ empire -& gt;gettotal(& quot;select count(*)as total from { $ dbtbpre } ecms _ & quot;。$ class _ r【$ classid】【TB name】。"其中classid = & amp#39;$ classid & amp#39;id = & amp#39;$ id & amp#39;限制1 & quot);如果(!$ num){ return JSON _ encode(array(& amp;#39;msgid & amp#39;= & gt1 & amp;#39;味精& amp#39;= & gt& amp#39;此產品不存在&;#39;));} $ record = & quot!";$ field = & quot| & quot;$productid=$classid。",& quot。$ id$ buy car = getcvar(& amp;#39;mybuycar & amp#39;);//重復if(strstr($ buy car,“| & quot。$productid。"| & quot)){ $ pr = explode(& quot;| & quot。$productid。"| & quot,$ buy car);$ pr1 =爆炸(& quot!",$ pr【1】);$ oldbuycar = & quot| & quot。$productid。"| & quot。$ pr1【0】。"!";//Quantity $ PR1【0】= returnbuyproduct num($ PR1【0】);if(empty($ pr1【0】)){ $ pr1【0】= 1;} $ new num = $ pr1【0】+1;$ newbuycar = & quot| & quot。$productid。"| & quot。$newnum。"!";$ buy car = str _ replace($ oldbuycar,$newbuycar,$ buy car);} else {//只有一個if($ public _ r【&;#39;buycarnum & amp#39;】= = 1){ $ buy car = & amp;#39;& amp#39;;} $buycar。= & quot| & quot。$productid。"|1!";} $ re = SetBuycar($ buycar);if($ re){ return JSON _ encode(array(& amp;#39;msgid & amp#39;= & gt2 & amp;#39;味精& amp#39;= & gt& amp#39;產品已成功添加到購物車&;#39;));} } echo JSON _ AddBuycar($ classid,$ id);db _ close();$ empire = null?& gt至此,無需刷新即可將帝國ECMS AJAX添加到購物車的功能已經完成。

推薦教程:帝國CMS教程

這幾篇文章你可能也喜歡:

本文由主機參考刊發,轉載請注明:帝國ECMS如何實現無需刷新即可加入購物車的AJAX(帝國CMS用戶手冊) http://www.k2270.com/110069.html

【騰訊云】領8888元采購禮包,搶爆款云服務器 每月 9元起,個人開發者加享折上折!
打賞
轉載請注明原文鏈接:主機參考 » 帝國ECMS如何實現無需刷新即可加入購物車的AJAX(帝國CMS用戶手冊)
主機參考僅做資料收集,不對商家任何信息及交易做信用擔保,購買前請注意風險,有交易糾紛請自行解決!請查閱:特別聲明

評論 搶沙發

評論前必須登錄!