1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP 5 e-commerce Development- P56 pptx

5 46 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 358,95 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

In this chapter, you will learn how to enable administrators to: Create a product, taking into account photographs and shipping Edit a product Create, edit, and manage categories View an

Trang 2

Administration Although our journey through creating an e-commerce framework is not yet at an

end, we are at the last primary feature: the administration area In this chapter, you

will learn how to enable administrators to:

Create a product, taking into account photographs and shipping

Edit a product

Create, edit, and manage categories

View and process orders

View customer profiles

View and create shipping methods and their corresponding rules

Create voucher codes

A suitable administration area can be broken down into four primary areas:

A dashboard: This area is used to provide administrators with a brief

overview of the store at any one time

Products and categories: This area is used to allow administrators to view,

create, edit, and delete products and categories

Orders and customers: This area is used to allow administrators to view and

process orders, as well as view customer profiles

Miscellaneous: This area could be used as somewhere for administrators

to change any settings, manage shipping methods, shipping rules, and

voucher codes

Trang 3

[ 260 ]

Dashboard

The dashboard should provide the administrator with an overview of the store; this

could include statistics such as:

The number of products and the number of categories they are

contained within

The number of customers

The number of orders that are awaiting dispatch (that is, orders that the

administrator needs to process)

Number of orders placed within the past 24 hours

The number of abandoned shopping baskets in the past 24 hours

The average cost of orders

Graphs and charts illustrating some of these statistics

Let's start with the basic statistics; we can generate most of the statistics from a

query, breaking the individual statistics into subqueries

$ts = date('Y-m-d h:i:s', strtotime('-1 day'));

$sql = "SELECT

(SELECT COUNT(*) FROM content c, content_types t

WHERE c.type=t.ID AND t.reference='product') AS num_products,

(SELECT COUNT(*) FROM users) AS num_customers,

(SELECT COUNT(*) FROM orders o, order_statuses os

WHERE o.status=os.ID AND os.name='Awaiting Dispatch')

AS num_orders_pending_dispatch,

(SELECT COUNT(*) FROM orders o, order_statuses os

WHERE o.status=os.ID AND os.name='Awaiting payment')

AS num_orders_pending_payment,

(SELECT COUNT(*) FROM orders o WHERE o.timestamp>'{$ts}')

AS num_orders_placed_24,

(SELECT FORMAT(AVG(products_cost),2) FROM orders)

AS avg_order_cost

FROM orders o LIMIT 1";

Trang 4

A sample dashboard screen is shown below:

We could extend and enhance this by adding some of the following:

Support for logging abandoned shopping baskets

Graphs and charts

Of these, the latter could probably be added using the Google Charts API or an

alternative suitable third-party chart service

Products and categories

For us to be able to sell anything on our site, we need to allow administrators to

create products in the store We also need to be able to edit and delete products, as

well as create, edit, and delete categories

Products

Let's look at how we can allow administrators to create, edit, and delete products

within our store

Creating a product

To create a product in our store, we need to:

Save standard information about the product such as the price, the name, the

description, and so on

Upload, resize, and save a photograph of the product

Upload additional photographs of the product

Trang 5

[ 262 ]

Save a shipping cost to be associated with the product, for each shipping

method we have in the store

Save the categories the product is part of

Save any configuration options, such as if the customer can upload a file

when placing the order, if the customer can enter any custom text, if the

product has a number of variants, particularly for apparel, for example red,

blue, and green t-shirts

A form such as the partial one below captures the relevant information:

Product photograph

When processing the create product form submission, we need to upload a

photograph and resize it to have a thumbnail and to keep the larger image

consistently sized

Photograph resizing with PHP

When resizing images with PHP, we need to use the function imagecreateresampled as opposed to imagecreateresized

If we use the latter, we will end up with distorted images

Ngày đăng: 07/07/2014, 10:20

TỪ KHÓA LIÊN QUAN