20150418--Product order + magnifying glass

Source: Internet
Author: User

first, the next order preparation:

Build table:

Order Information table: Store the main order information

Order ID, ID of the logged in user, total amount of the order, information of the consignee of the order

1 123 400 Liang

An association table for orders and commodities

The ID of the item the ID of the product the property ID of the purchased Quantity item Unit price

1 12 23,45 10 10

1 24 45,67 10 20

1 67 20 5

#创建一个订单信息表

CREATE TABLE It_order (

ID smallint unsigned primary key auto_increment,

user_id smallint unsigned NOT NULL comment ' login user's id ',

ORDER_SN varchar (+) NOT NULL comment ' order number ',

Total_price decimal (10,2) NOT NULL comment ' Total amount of order ',

Consignee varchar (+) NOT null comment ' consignee's name ',

Address varchar (+) NOT null comment ' consignee addresses ',

Mobile char (one) not null comment ' consignee's phone ',

Pay_status tinyint NOT null default 0 comment ' payment status 0 means unpaid, 1 means already paid ',

Shipping varchar (TEN) NOT null comment ' delivery method ',

Payment varchar (TEN) NOT null comment ' payment method '

) engine MyISAM charset UTF8;

#创建一个订单商品表

CREATE TABLE It_order_goods (

ID smallint unsigned primary key auto_increment,

order_id smallint unsigned NOT NULL comment ' order ID ',

goods_id smallint NOT NULL comment ' Product ID ',

goods_attr_id varchar (+) NOT null default ' comment ' commodity attribute id ',

Goods_number tinyint unsigned not null comment ' purchase quantity ',

Goods_price decimal (10,2) NOT null comment ' unit price of purchased item '

) engine MyISAM charset UTF8;

#创建一个收货人的信息表

CREATE TABLE it_address (

ID smallint unsigned primary key auto_increment,

Consignee varchar (+) NOT null comment ' consignee's name ',

Tel varchar (p) NOT null comment ' consignee's phone ',

Mobile char (one) not null comment ' consignee's mobile phone ',

Address varchar (+) NOT null comment ' consignee addresses ',

Post char (6) NOT null comment ' consignee's zip code '

) engine MyISAM charset UTF8;

1, add a connection in the Shopping Cart list page, enter the next step to complete the order.

2, add a Order1 method in the CART controller, the first step to place the order.

In this method: To complete the verification that the user is logged in, if not logged in, jump to the login page, after the login is complete, and then jump back.

To complete the login user whether to fill in the consignee's information, if not filled out then jump to fill the page.

(1) Determine if the user is logged in.

To modify the login method inside the UserController.class.php

(2) Determine whether the user fills in the consignee's information

Create a new writeaddress below the current controller to fill in the consignee's information.

and copy the corresponding static page, and modify the form

(3) Traversing the extracted data

The code inside the final controller:

second, start placing orders

1, to order1.html page Modify the form, add hidden fields.

2, start to write code into the library.

3, two issues need to be considered;

One is high concurrent placing of orders.

100 Items in Stock

A Buy 100 can

b Buy 100 can

One is a transactional issue.

The table to manipulate,

To use the InnoDB engine, It_goods table (inventory table) It_order Table It_order_goods table

To open a transaction:

mysql_query (' START TRANSACTION ');

To roll back a transaction:

mysql_query (' ROLLBACK ');

Commit TRANSACTION:

mysql_query (' COMMIT ');

third, the background order list, take out the corresponding product data

1. Create an order module in the background to create the Ordercontroller controller.

2. Add mouse over events to the order number area

Add a hidden div to the Order list page

Add an event to the order number area,

3, use Ajax to take out the goods in the specific order,

JS Code:

4, the method defined in the order controller, the Showgoods method.

Showgoods method, corresponding to the template page traversal data

Iv. Achieve Magnifier effect, use a plug-in

v. Browsing History

Idea: Browsing history is saved in a cookie.

When browsing the Product Details page, add the browsing information to the cookie

20150418--Product order + magnifying glass

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.