Cách làm giỏ hàng

1. Hiển thị số lượng trong giỏ hàng
<iif-F><Source><type:session/>Cart_iif</>/App_Data/Cart.xml</Source><Compute>Count(_SYS_KEY)</></>x</Compute><ItemF><%i=x=i%></ItemF></iif-F>

2. Tạo trang giỏ hàng trong hệ thống
+ Tải file xml trang: Tải file
+ Tải file mẫu html: Tải file

3. Câu hình ở trang sản phẩm
 3.1 Cách làm ở trang danh sách sản phẩm có nút Đặt hàng
- Tạo hàm trong trang xử lý:
<script>
function send_ord(id,tieude,img,link,gia,sl)
{

  $.post("/gio-hang/luu-gio-hang",
  {
    Name: tieude,
    ID_Product: id,
    Image: img,
    Link: link,
    UnitPrice: gia,
    Amount: sl,
    ___FIND_ROW: "ID_Product='"+id+"'"
    
  },
  function(data, status){
       $.get("/gio-hang/dem-so-luong", function(data, status){
            $(".qty").html(data);     //đứa tổng số dòng vào class qty      
            $(".qty_p").html(data);        // số lượng trong cửa số popup hiện lên
            $('#theodoi').modal('show');    //hiển thị cửa số popup
            //window.location.reload();
       });

  });
}
</script>

 

- Gán lệnh gọi đến hàm send_ord
Nút này để trong vòng lặp in ra sản phẩm:
  <button onclick="send_ord(<%i=ID_NoiDung_Web=i%>
,'<%i=TieuDe=i%>'
,'<%i=LinkAnhMin=i%>'
,'<%i=NameUrl=i%>'
,'<%i=CotGia=i%>'
,1)"><i class="fa fa-shopping-cart"></i> Thêm Giỏ Hàng</button>


* CotGia: tùy vào cấu hình, có thể là ThamSoKieuSo_01 ....

  3.3 Cách làm ở trang chi tiết sản phẩm có nút Đặt hàng
- Tạo hàm trong trang xử lý:
  <form action="/gio-hang/luu-gio-hang" method=post>                    
<input type="number" name="Amount" value="1">                            
<input name="UnitPrice" type="hidden" value="<%=ThamSoKieuSo_02=%>" />            
<input name="Name" type="hidden" value="<%=TieuDe=%>" />
<input name="ID_Product" type="hidden" value="<%=ID_NoiDung_Web=%>" />
<input name="Image" type="hidden" value="<%=LinkAnhMin=%>" />
<input name="Link" type="hidden" value="<%=NameUrl=%>" />
<!-- UPDATE  -->
<input name="___FIND_ROW" type="hidden" value="ID_Product='<%=ID_NoiDung_Web=%>'" />                
<input name="___REDIRECT_PAGE" type="hidden" value="/gio-hang" />
<button type="submit"> Mua Ngay</button>                
</form>   

dffdf
 

Mục liên quan: