[英]asp.net shopping cart update quantity in cookie
in shopping cart web page i have this list view to show items in cart: 在购物车网页中,我具有此列表视图以显示购物车中的物品:
<asp:ListView ID="List" runat="server" DataKeyNames="ID">
<table class="tbl">
<tr>
<td class="one">
<h4><%# Eval("ID")%></h4>
</td>
<td class="two">
<h4><%# Eval("Name")%></h4>
</td>
<td class="fone"><%# Eval("Total")%></td>
<td>
<asp:DropDownList runat="server" CssClass='drop' SelectedValue='<%# Eval("Qty")%>'>
<asp:ListItem value="1">1</asp:ListItem>
<asp:ListItem value="2">2</asp:ListItem>
<asp:ListItem value="3">3</asp:ListItem>
<asp:ListItem value="4">4</asp:ListItem>
</asp:DropDownList>
</td>
<td class="ffour"><%# Eval("Price")%></td>
</tr>
</table>
items retrieve from cookie .when user add item to cart, item added to this listview . 从cookie检索项目。当用户将项目添加到购物车时,项目已添加到此listview。 i have written jquery code to, when user change quantity of one item , totalprice automatically has been changed . 我已经编写了jQuery代码,当用户更改一件商品的数量时,totalprice已自动更改。
$('.drop').on('change', function () {
var tr = $(this).closest('tr');
var price = $(tr).find('.ffour').html();
$(tr).find('.fone').html(price * $(this).val());
});
how to do when user change quantity , qty in cookie changes too?for example , when user change quantity of first row from 1 to 2 , in website cookie , qty changes from 1 to 2 . 当用户更改数量时,cookie中的数量也会发生变化?例如,当用户将第一行的数量从1更改为2时,网站cookie中的数量从1更改为2。
name of cookie is 'SiteCookie' . Cookie的名称为'SiteCookie'。 and has Qty for quantity of products. 并且具有产品数量的数量。
First of all Take this js for Cookies and then 首先,将此js用作Cookies ,然后
$('.drop').on('change', function () {
$.cookie("qty",$(this).closest('tr'))
var price = $(tr).find('.ffour').html();
$(tr).find('.fone').html(price * $.cookie("qty"));
});
On page load as well u can call cookie... if cookie has value then perform this 在页面加载时,您也可以调用cookie ...如果cookie具有价值,则执行此操作
$(tr).find('.fone').html(price * $.cookie("qty"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.