當前位置:首頁 » 網頁前端 » web購物車數量
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

web購物車數量

發布時間: 2022-08-12 06:28:20

⑴ 京東淘寶天貓的購物車里最多可以放多少東西

好像是論件兒算的,一共可以放99種,超過的話,系統就會提示你購物車已滿,要求你清除之後再重新添加。你不妨自己可以試一下呀。

⑵ java web 做購物車的大概思路,和實現步奏是什麼

購物車管理模塊主要功能有如下幾個部分:(1)創建購物車 當客戶登錄後,系統會給客戶創建一個購物車放入伺服器的Session會話中。使客戶在整個會話中都擁有一個相同的購物車。這里主要運用了Http協議中的會話機制,將購物車保存在客戶的會話中,這樣在整個客戶游覽不同頁面商品的過程中,都會使用同一個購物車對象。 具體執行步驟:(1)從客戶的請求對象中獲取Session會話對象(2)從會話對象中獲取購物車對象(3)判斷是購物車對象是不是空的,如果是空是就創建一個 /* * 在監聽到session被創建之後,就立即向session中添加一個購物車Car; */ public void sessionCreated(HttpSessionEvent arg0) { HttpSession session = arg0.getSession(); Cart cart=new Cart(); session.setAttribute("cart", cart); } /* * 從session中獲得購物車 */ Cart cart = (Cart) session.getAttribute("cart"); if (cart == null) { cart = new Cart(); }(2)向購物車中添加一個商品項 客戶在查看網頁上的一個商品時,當向伺服器發送一個「添加到購物車」的請求時,會執行這個功能。功能執行過程:(1)從客戶請求對象中獲取商品的ID(2)調用業務層的方法根據商品ID去數據查詢商品的信息,返回商品對象(3)從商品對象中獲取商品名,商品價格,來構建一個商品項對象(4)從Session會話中獲取購物車對象(5)調用業務層的方法來根據購物車對象和商品項對象來執行添加操作(6)將些商品項對象放入到購物車中 部分實現代碼: /* * 從資料庫中把商品取到; */ ProctService proctService = (ProctService) ServiceFactory.getInstance().getService(Globals.PRODUCT_SERVICE); Integer id = Integer.parseInt(request.getParameter("proctid")); Proct proct = proctService.getProctById(id); /* * 在向購物車中添加商品的時候會判斷商品是否已經存在, * 已存在的就不讓在加入了; */ if (cart.isExist(id)) { message = "該商品已經存在!請<a onclick='javascript:history.go(-1)'>返回</a>!"; request.setAttribute("message", message); return mapping.findForward("error"); } else { /* * 向購物車添加一個商品; */ cart.addCart(proct); session.setAttribute("cart", cart); return mapping.findForward("addcartsuccess"); }

⑶ 用html做一個購物車,能實現簡單的產品數量和價格的加減就行。最後能計算出提交物品價格的總和。

html中的購物車的增減不能直接傳送到後台,可以通過ajax,在js中發送ajax

前端的話可以參考下面的

<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>cart</title>
<styletype="text/css">
body,p,a,input{
margin:0;
padding:0;
font-size:12px;
}

.container{
width:100%;
}

.main{
width:1000px;
height:500px;

margin:100pxauto;
}

.main.cart-containertable{
width:100%;}

.main.cart-containertabletr{
text-align:center;

}

.main.cart-containertabletr:hover{
background:rgba(128,128,128,0.2);
}
.main.cart-containertable.table-header{
height:30px;
background:#d9d9d9;

font-size:1.2em;

}

.main.cart-containertable.table-headertd:first-child{
border-left:solid4pxred;
box-sizing:border-box;
}

.main.cart-containertabletrtd:nth-child(1),
.main.cart-containertabletrtd:nth-child(2){
text-align:left;

}

.main.cart-containertabletrtd:nth-child(2){
width:52%;
}
.main.cart-containertabletrtd:nth-child(3){
width:12%;
}
.main.cart-containertabletrtd:nth-child(4){
width:12%;
}
.main.cart-containertabletrtd:nth-child(5){
width:12%;
}
.main.cart-containertabletrtd:last-child{
width:10%;
}

.cart-good{

height:60px;
}
.cart-goodimg{
float:left;
margin:10px;
width:60px;
}

.cart-goodtdp{
margin:10px0px;
}


/*加、減按鈕*/

.cart-goodtdinput[type='button']{
width:20px;
height:20px;
background:#00f300;
outline:none;
border:none;
}

.cart-goodtdinput[type='button']:disabled{
background:grey;
}

.cart-goodtdinput[type='button']:first-child{
margin-right:-4px;
}
.cart-goodtdinput[type='button']:last-child{
margin-left:-4px;
}
.cart-goodtdinput[type='text']{
width:30px;
height:20px;
outline:none;
border:none;
text-align:center;


}


.table-footer{
display:flex;
justify-content:space-between;
line-height:40px;
}


.table-footerdiv{
font-size:1.2em;

}
.table-footerdivbutton{
background:red;
width:120px;
height:40px;
color:white;
}
</style>
</head>
<body>
<divclass="container">
<header></header>
<sectionclass="main">
<divclass="cart-container">
<tablecellspacing="0">
<trclass="table-header">
<td><inputtype="checkbox"id="chk_alla"></td>
<td>聚美優品發貨</td>
<td>聚美價</td>
<td>數量</td>
<td>小計</td>
<td>操作</td>
</tr>
<!--<trclass="cart-good">-->
<!--<td><inputtype="checkbox"id="001"></td>-->
<!--<td>-->
<!--<imgsrc="https://p2.jmstatic.com/proct/001/293/1293263_std/1293263_60_60.jpg"alt="">-->
<!--<p>[極速免稅]PITTAMASK口罩3枚入</p>-->
<!--<p>型號:新版防曬款容量:3枚入</p>-->
<!--</td>-->
<!--<td>89.00</td>-->
<!--<td>-->
<!--<inputtype="button"value="-">-->
<!--<inputtype="text"value="1">-->
<!--<inputtype="button"value="+">-->
<!--</td>-->
<!--<td>89.00</td>-->
<!--<td><ahref="#">刪除</a></td>-->
<!--</tr>-->
</table>
<divclass="table-footer">
<div>
<inputtype="checkbox"id="chk_allb"><labelfor="chk_allb">全選</label>
<spanstyle="margin-left:20px">繼續購物|清空選中商品</span>
</div>
<div>
共<spanid="good_count">5</span>件商品商品應付總額:<spanid="goods_total">¥229.00</span>
<buttonclass="btn_menu">去結算</button>
</div>
</div>
</div>
</section>
</div>
<script>
(function(){
varskin_procts=[
{
"id":"002",
"title":"EsteeLauder多效智妍精華霜15ml",
"img_url":"http://p0.jmstatic.com/proct/003/565/3565880_std/3565880_350_350.jpg",
"price":249.0,
"number":6,
"acount":"520",
"ischecked":true
},
{
"id":"004",
"title":"EsteeLauder肌透修護潔面乳30ml",
"img_url":"http://p4.jmstatic.com/proct/003/155/3155764_std/3155764_350_350.jpg",
"price":49.9,
"number":1,
"acount":"5911",
"ischecked":false
},
{
"id":"008",
"title":"雅詩蘭黛無痕持妝粉底液",
"img_url":"http://p3.jmstatic.com/proct/003/662/3662318_std/3662318_350_350.jpg",
"price":69.9,
"number":2,
"acount":"3972",
"ischecked":true
},
{
"id":"0012",
"title":"EsteeLauder肌初賦活原生液30ml",
"img_url":"http://p4.jmstatic.com/proct/003/565/3565914_std/3565914_350_350.jpg",
"price":159.0,
"number":1,
"acount":"2338"
},
{
"id":"001",
"title":"雅詩蘭黛無痕持妝粉底液30ml",
"img_url":"http://p2.jmstatic.com/proct/001/648/1648502_std/1648502_350_350.jpg",
"price":298.0,
"number":4,
"acount":"5071",
"ischecked":false
},
{
"id":"009",
"title":"雅詩蘭黛眼部精華霜15ml",
"img_url":"http://p1.jmstatic.com/proct/001/049/1049746_std/1049746_350_350.jpg",
"price":399.0,
"number":1,
"acount":"4022",
"ischecked":false
}
]

//添加商品

functionload(){
vartbody=document.querySelector('.cart-containertabletbody');
for(letgoodofskin_procts){
tbody.innerHTML+=`<trclass="cart-good"id="${good.id}">
<td><inputtype="checkbox"class="good-check"${good.ischecked?"checked":''}></td>
<td>

<imgsrc="${good.img_url}"alt="">
<p>[極速免稅]PITTAMASK口罩3枚入</p>
<p>型號:新版防曬款容量:3枚入</p>

</td>
<td>${good.price}</td>
<td>

<inputtype="button"value="-"${good.number<=1?"disabled":''}>
<inputtype="text"value="${good.number}">
<inputtype="button"value="+">
</td>
<td>${good.price*good.number}</td>
<td><ahref="#">刪除</a></td>
</tr>`
}

totalAcount();
}
load();
//endall..........

//1.為table注冊單擊事件

vartable01=document.querySelector('.cart-containertable');

table01.onclick=function(event){

varnode=event.target
if(node.getAttribute('type')=='button'){
//alert(event.target.value);
changeNumber(event);
subtotal(event);
checkedRow(event);
checkedAllRows();

}elseif(node.className=='good-check'){
checkedAllRows();

}elseif(node.id=='chk_alla'){
varf=event.target.checked;
varchks=document.querySelectorAll('.good-check');
for(varckofchks){
ck.checked=f;
}

for(vargoodofskin_procts){
good.ischecked=f;
}


}elseif(node.nodeName.toLowerCase()=='a'){
vartr=event.target.parentNode.parentNode;
for(vari=0;i<skin_procts.length;i++){
if(skin_procts[i].id==tr.id){
skin_procts.splice(i,1);
console.log(skin_procts);
}
}

tr.parentNode.removeChild(tr);

}
totalAcount();
};

//單擊增加或減少按鈕的方法
functionchangeNumber(event){

varnode=event&&event.target;
varv=0;
if(node.value&&node.value=='+'){
//node.previousElementSibling.value=parseInt(node.previousElementSibling.value)+1;
node.previousElementSibling.value++;
v=node.previousElementSibling.value;
node.previousElementSibling.previousElementSibling.disabled=false;

}else{
//if(node.value&&node.value=='+')
if(node.nextElementSibling.value>1){
node.nextElementSibling.value--;
v=node.nextElementSibling.value;
if(v==1){
node.disabled=true;
}
}
}


//存儲商品數量

varid=node.parentNode.parentNode.id;

for(vargoodofskin_procts){
if(id==good.id){
good.number=v;
}
}

}

//每個商品小計的方法

functionsubtotal(event){
varnode=event&&event.target;

//varid=node.parentNode.parentNode.id;

//for(vargofskin_procts){
//if(g.id==id){
//alert(g.price);
//}
//}


//varprice=;

varprice=node.parentNode.previousElementSibling.innerText;
varnum=node.parentNode.children[1].value;
node.parentNode.nextElementSibling.innerText=(num*price).toFixed(2);
}

//檢驗該商品是否選中
functioncheckedRow(event){
event.target.parentNode.parentNode.firstElementChild.firstElementChild.checked=true;
//event.target.parentNode.parentNode.cells[0].firstElementChild.checked=true;
//vartbody=event.target.parentNode.parentNode.parentNode;
//event.target.parentNode.parentNode.parentNode.rows[3].cells[0].firstElementChild.checked=true;
}
//檢查是否全選

functioncheckedAllRows(){
varchks=document.querySelectorAll('.good-check');
varflag=true;
for(varckofchks){
if(!ck.checked){
flag=false;
break;
}
}
document.querySelector('#chk_alla').checked=flag;

}


//統計商品總量和總價格

functiontotalAcount(){

vartotal=0;
vartotal_price=0;
varchks=document.querySelectorAll('.good-check');
for(varckofchks){
if(ck.checked){
id=ck.parentNode.parentNode.id;
for(vargoodofskin_procts){
if(id==good.id){
total+=~~good.number;
total_price=total_price+(good.number*good.price);
good.ischecked=true;


}
}


}
}

document.querySelector('#good_count').innerText=total;
document.querySelector('#goods_total').innerText=total_price;


}

})();
</script>
</body>
</html>

⑷ jsp購物車計算數量的問題!

總計只能是每次改動要更新一次咯。沒次算完小計後,再吧所有小計加起來得總計。

⑸ java web 購物車怎麼刪除 並且有數量改變用session 和 cookie 實現代碼

附件為使用session實現了購物車功能,包括添加商品到購物車、修改數量和刪除購物車商品信息功能!

⑹ 購物車上限是多少

一般情況下淘寶購物車最多120個,收藏夾最多2000個,淘寶大促活動的時候,購物車的上限會臨時提升到150個

如果消費者的購物車中的數量太多,而且用戶一次性提交太多的訂單,那麼會導致數據系統紊亂,這樣會造成買賣雙方的困擾。

(6)web購物車數量擴展閱讀

使用購物車的優點:

1、 放入購物車中的商品不是真正的拍下商品,如果不是立即購買商品,也是可以用來收藏商品方便下次購買。

正所謂貨比三家,當你看到了一款相當不錯的商品,有了購買的意思,但是又擔心可能待會還會找到更好的,就可以先把商品放入購物車,繼續瀏覽,到最後再進行比較,是刪是留,自己決定了。

2、 在購物車里可以找剛才拍下的商品,並且可以修改數量或者改變主意不選購該商品。

3、 在多家店鋪里加入購物車里的商品,在購物車內會自動分類到各自的商鋪,可以選擇此次准備付款的商品,沒有選擇的不會被拍下,商品還會保存在購物車中直到寶貝過期或刪除該寶貝。

⑺ 淘寶網的購物車最多可以放多少件寶貝

購物車99件,同一家拍貨最多50件不同物品一單,多出重新拍。

據淘寶官方的說法,這主要是為了防止部分買家無限制囤貨以及保障網站的正常運行,如果不限制購物車將對買家以及網站運行造成不利影響。但在去年雙十一期間淘寶臨時取消了這種限制。

對於資深剁手黨來說,99件的購物車限制明顯影響到了其購買欲,有用戶別出心裁的推出了「購物車出租」的服務,據悉已經有多位買家購買。

資料拓展

淘寶網是亞太地區較大的網路零售、商圈,由阿里巴巴集團在2003年5月創立。淘寶網[1]是中國深受歡迎的網購零售平台,擁有近5億的注冊用戶數,每天有超過6000萬的固定訪客,同時每天的在線商品數已經超過了8億件,平均每分鍾售出4.8萬件商品。[1]

截止2011年年底,淘寶網單日交易額峰值達到43.8億元,創造270.8萬直接 且充分就業機會。隨著淘寶網規模的擴大和用戶數量的增加,淘寶也從單一的C2C網路集市變成了包括C2C、團購、分銷、拍賣等多種電子商務模式在內的綜合性零售商圈。目前已經成為世界范圍的電子商務交易平台之一。


網路 淘寶

⑻ 網友反映淘寶的購物車是有上限的,購物車的上限是多少

網友反映淘寶的購物車是有上限的,購物車的上限是120件,我覺得其實這樣也是很好的,因為大家也不是加購了120件產品,就會購買120件產品的,所以也是會給消費者一個考慮的時間,就是有些產品不需要的話,就可以把它刪除掉,然後把自己更需要的產品,自己更心動的產品留在購物車裡面。


最近雙11活動開始了,我想大家的購物車已經加購了很多的商品吧,但是我也希望大家能夠理性消費,快樂購物,因為不是所有的產品都是我們必須的,我們自己還是需要存一些錢來,以便不時之需的,不能把所有的錢都用來購買產品。不過我覺得雙11的產品真的好便宜啊,所以如果有足夠多的錢的話,可以買一些生活的必需品,囤起來也是一個很不錯的選擇。真的,我想說買東西的時候就特別的希望自己是一個富豪,這樣子的話,我想買什麼就能買什麼了,而不是在幾件商品當中挑挑選選的。

⑼ 淘寶的購物車上限是多少你覺得夠用嗎

夠用啊。

很多人覺得這個設置不合理,就像拍腦袋決定的,其實關於淘寶購物車上限的值,是經過精挑細選才敲定的,裡面的學問可大著呢!究竟是為什麼,淘寶只給你120次加入購物車的機會?

第三個原因應該是技術原因,當購物車中的數量太多,而一次性提交太多的下單,會導致數據系統紊亂,這樣會造成買賣雙方的困擾。而控制購物車的總量會更好的對接支付系統,防止支付擁堵。

最後,120這個數字到底如何敲定的。120接近150,這就讓人想到了營銷界大名鼎鼎的“150定律”。“150定律”是英國牛津大學人類學家羅賓.丹伯提出的。主要內容是內容:一個人不可能與超過150個人維持持續穩定的社會關系,社會交流的必須禮儀使得我們有意的范圍限制在150人以內。如果群體變得太大,就會分出新的群體。

150是人類社交極限,是一個人在自己最大能力內能維持的社交人數。淘寶在設置購物車天花板時顯然考慮到了“150定律”,如果超過150,用戶維護起來也會有負擔。但如果消費者真的有大於120件的寶貝要買,現在也不乏有購物車出租對的服務。

通過對以上內容的了解,可以看出,這個購物車的數量限制在120件,當你再將第121件加入購物車的時候,它就會提醒您購物車已滿,無法在繼續加入其中了,所以要注意去清空購物車哦。