简单购物车的实现

本文深入探讨了电商网站购物车功能的实现,包括商品展示、购物车操作、订单生成及支付流程。详细介绍了如何通过Cookie和Session技术管理用户会话,构建了从商品浏览到结账的全流程,确保用户体验流畅且安全。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

购物车的实现

1、http://www.taobao.com

2、功能

          1)商品展示――相关资料(基本描述、价格、名称、供应商情况、图片等)

          2)购物车功能

                  购物车相当于现实中超市的购物车,但是网页实现的是虚拟的一种行为。用户可以在购物网站不同页面之间任意跳转,选购自己喜欢的商品――点击购买――订单   息――统一到付账台结账

 

购物车功能包括

      1)添加商品――订购

      2)删除商品

      3)修改商品的购买数量(小计、总计)

      4)清空购物车

3、  订单

详细信息表单

选择支付方式――支付宝接口

 

第一步:选择方法

关键:服务器要求识别每一个用户并且能维持与他们的联系。

   HTTP:无状态(stateless)

            Cookie、session  session+mysql

         Cookie:  是由服务器产生、存储在客户端一段信息记录

     包含:域、(客户端浏览器上禁用的是服务器端行为)、路径、生存周期、变量名、变量值等

     容量:每个cookie的大小4kb 

    占用服务器端资源少,浏览器允许存放300个cookie;

              Cookie是浏览器内置的功能,浏览器关闭信息也不会丢失。

       基于cookie技术实现的购物车需要开启cookie功能;

     存在侵权问题;

Session:

   特点:

    不依赖于客户端设置(存放到服务器端)

    Session与cookie更安全、信息更多;

    会占用服务器资源

 注意:

   基于cookie:

          使用URL:

 

Session方法

第二步:创建数据库

Db_shopping_car

     用户表:登录(识别身份)

 商品表:商品展示

 订单表:实现订单

    

卖家

 Createtable admin(

     Id int unsigned not null primary key auto_increment,

     Admin_name  varchar(30) not null,

     Admin_password varchar(30) not null,

     Admin_photo varchar(100) not null,

     Admin_email varchar(30) not null

     );

 

买家

Create table customer(

Id int unsignednot null primary key auto_increment,

C_name varchar(30)not null,

C_pass  varchar(30) not null,

C_photo  varchar(100) not null,

C_questionvarchar(100) not null,

C_addressvarchar(300)not null,

C_email  varchar(100)not null,

C_level   char(1) not null,

C_num    int not null,

);

客户反馈信息

 Create table idea(

    Id int unsigned not null primary keyauto_increment,

    C_name varchar(30) not null,

    C_photo varchar(100)not null,

    New_message varchar(100) not null ,   

Re_message varchar(100) not null,

New_time date not null,

    Re_time   date    not null,

   

 

);

 

产品表

Create table produnct(

  Idint unsigned not null primary key auto_increment,

  P_namevarchar(20) not null,       商品的名字

 P_type  int  not null,      商品的类别:日用百货,家电

    产品类别表中id 为主键,该字段在 product 里应为外键

  P_pricedecimal(10,2) not null,     商品的价格

  P_quantityint not null,       商品的数量

  P_imagevarchar(100) not null,    商品的图片

  P_describevarchar text not null,   商品的简单描述

  P_timevarchar(50) not null,   // 商品的发布时间

  P_zkfloat not null,         //商品的折扣

  P_publisheripvarchar(50) not null, //  发布得ip

  P_updatetimevarchar(30) not null, //最后更新的时间

  P_userip  varchar(300) not null,  //最后更新的用户

 

);

 

create table p_type(

Id int unsigned not null primaryu keyauto_increment,

Type_Name varchar(30) not null,

Desc text not null

);

 

 

第三部分 订单表

 

Create tableorders(

Order_id intunsigned not null primary key auto_increment,//订单序列号

Order_numvarchar(50) not null , //订单号------20111031_pid_phone

Order_email  varchar(30) not null, 收件人信息

Order_user  varchar(30) not null,  收件人姓名

Order_time   varchar(50) not null,  订单时间

    客户提交订单—商家确认—客户支付—商家发货-product表

Order_status enum (‘0’,’1’,’2’) not null

   

    订单状态:未支付0、已支付未发货1、已支付已发货2

);

 

详细订单表

 Createtable order_detail(

   id int unsigned not null primary keyauto_increment,

 

   Order_id int not null,

   P_id int not null,

   P_price decimal(10,2) not null,

   P_des text not null,

   P_num int not null,

   P_zk float not null,

  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值