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

PHP 5 e-commerce Development- P66 pdf

5 194 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 334,86 KB

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

Nội dung

By suitably integrating the API with our framework, we could: Automatically list our products on Amazon marketplace Automatically remove our products from Amazon marketplace when stock l

Trang 1

Interacting with Web Services

[ 308 ]

This is reflected in the JavaScript as follows:

pageTracker._addTrans(

"111", // the order ID - this is a required field

"Props", // affiliation or store name

"10.50", // total - required

"0.00", // tax

"10.00", // shipping

"Newcastle", // city

"Tyne and Wear", // state or province

"UK" // country

);

Add item

For each item within the transaction, we must record:

The order ID

The product code or stock keeping unit (SKU)

The unit price for the item

The quantity of the item

We can also record:

The product name

The category or variation of the product

This is reflected in the JavaScript as follows:

pageTracker._addItem(

"111", // order ID - necessary to associate item with transaction

"P1", // SKU/code - required

"Fake Water Jug", // product name

"Large", // category or variation

"10.50", // unit price - required

"1" // quantity - required

);

Track transaction

Once the transaction, and all items within the transaction, have all been added,

we track the transaction, by issuing the following JavaScript call:

pageTracker._trackTrans();

Trang 2

Appendix A

Further reading

• Tracking number of sales (but nothing else)—Analytics Talk—http://

www.epikone.com/blog/2008/06/25/google-analytics-e-commerce-tracking-pt-3-why-everyone-should-use-it/

Tracking lead generation forms (http://www.epikone.com/

blog/2008/07/02/google-analytics-e-commerce-tracking-pt-4-tacking-lead-gen-forms/)

Tracking API: e-commerce (http://code.google.com/apis/analytics/

docs/gaJS/gaJSApiEcommerce.html)

Other services

Both Amazon and eBay (along with a number of other retailers) have APIs that allow

developers to sell products by listing them using an API

Amazon

Amazon's Marketplace Web Service (Amazon MWS) allows sellers to list items for

sale on the Amazon marketplace through an API By using this, we could automate

the process of listing products we have in our own e-commerce store, on the Amazon

marketplace website This would extend opportunities for new customers to do

business with us By suitably integrating the API with our framework, we could:

Automatically list our products on Amazon marketplace

Automatically remove our products from Amazon marketplace when stock

levels are low

A PHP client library is available for the Amazon MWS API, which can be used to

integrate with our framework: http://mws.amazon.com/phpClientLibrary.html

eBay

eBay has a developer center for various languages and APIs, including searching,

managing feedback, and of course, creating listings With this API we could:

Automatically create listings based on new products

Automatically create repeat listings for existing products that are still in stock

(perhaps, generating new ones each week)

Automatically post good feedback to the buyer once the order is complete

Trang 3

Interacting with Web Services

[ 310 ]

A number of PHP resources are available for working with the API, including

ones specific for their trading API, which would be of most use to us Some of

these include:

http://developer.ebay.com/developercenter/php/

http://developer.ebay.com/developercenter/php/trading/

More to come

There are a few more web services, which we will look at interacting with in

Appendix C, Cookbook.

Summary

In this chapter, we have primarily looked at the Google merchant center and how we

would create a data feed of products which would automatically update with our

product catalog, to keep our information constantly up to date in Google product

search We also had a brief look at:

What similar services are available

Google Analytics:

Tacking website statistics Tracking sales

Order data Item data Amazon web services

eBay developer center

°

°

Trang 4

Downloadable Products

In this appendix, we are going to look at how we would rapidly extend our

framework to allow downloadable products In this chapter, you will learn:

How to extend the types of products available in the framework

How to extend the payment and administration areas to unlock

downloadable products when payment is made

How to lock access to downloaded products when payment is refunded

How to create a centralized download area for customers to access

downloadable products

This is a very basic implementation of downloadable products functionality Ideally,

we would also look into storing the files in a location that isn't accessible through the

Web We would then either copy the file for each user who purchases the product in

a unique location, or create a script, which when an authorized user copies the file,

temporarily to a public location, allows a single download, and then removes

that copy

Extending products

When we abstracted out content earlier in the book, we separated product-specific

data in a table, content_types_products This is the table we need to extend to

enable downloadable products

We should just need to add two new fields to this table:

Downloadable: This indicates if the product is downloadable.

File: This indicates the name of the file.

Trang 5

Downloadable Products

[ 312 ]

We also need to define a setting, which will be the location of files that are

downloadable products

ALTER TABLE `content_types_products`

ADD `downloadable` BOOL NOT NULL DEFAULT '0',

ADD `file` VARCHAR( 255 ) NULL

Extending the payment and

administration areas

To extend the payment and administration areas to allow customers to download

the files for their purchases, we should create a centralized record of these types of

purchases (we will discuss this later in more detail) This makes providing a nice

download area much easier

At this stage, there are three things we need to do:

Create a new database table relating customers to their downloadable

purchases

Update the payment methods to automatically provide access to these

downloads by creating new records in the new table when payment

is received

Update the payment methods to automatically remove access to these

downloads by removing records from the new table when orders are

updated to "refunded"

Access database

Our table for providing access to download files needs the following fields::

An ID

A reference to the customer's ID

A reference to the product ID

The date access was granted

The location of the file

The location at present will just be copied from the products table However, it

makes things easier for us if we extend the functionality to create a separate copy

of the file for each customer

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

TỪ KHÓA LIÊN QUAN