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

PHP 5 e-commerce Development- P46 doc

5 77 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

Tiêu đề Shipping and Tax
Trường học Standard University
Chuyên ngành E-commerce Development
Thể loại Bài luận
Năm xuất bản 2010
Thành phố Brick
Định dạng
Số trang 5
Dung lượng 293,21 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 some situations we can include the tax for a product in its price; it doesn't need to be displayed to the customer.. In others, we may wish for tax to be shown and calculated for the

Trang 1

{ if( $this->shippingCost > $rule['match_amount'] )

{ $match = true; } }

elseif( $match_operator == '<' )

{ if( $this->shippingCost < $rule['match_amount'] )

{ $match = true; } }

If a rule match was found, we then take the rule into account

if( $match == true )

{

// set the shipping cost based on the rule operator and

// the rule amount

$rule_operator = $rule['rule_operator'];

if( $rule_operator == '=' )

{ $this->shippingCost = $rule['rule_amount']; }

elseif( $rule_operator == '+' )

{ $this->shippingCost = $this->shippingCost

+ $rule['rule_amount']; }

elseif( $rule_operator == '-' )

{ $this->shippingCost = $this->shippingCost

- $rule['rule_amount']; }

elseif( $rule_operator == '*' )

{ $this->shippingCost = $this->shippingCost

* $rule['rule_amount']; }

elseif( $rule_operator == '/' )

{ $this->shippingCost = $this->shippingCost

/ $rule['rule_amount']; }

}

}

If the product is based on the basket cost, we then do the same as before, except that

the rule matching depends on the cost of the shopping basket

elseif( $rule['match_type'] == 'products' )

{

// rule depends on the basket cost

$match = false;

$match_operator = $rule['match_operator'];

// check to see our basket cost meets the rule

if( $match_operator == '==' )

{ if( $this->shippingCost == $rule['match_amount'] )

{ $match = true; } }

elseif( $match_operator == '<>' )

{ if( $this->cost <> $rule['match_amount'] )

{ $match = true; } }

elseif( $match_operator == '>=' )

{ if( $this->cost >= $rule['match_amount'] )

{ $match = true; } }

Trang 2

elseif( $match_operator == '<=' )

{ if( $this->cost <= $rule['match_amount'] )

{ $match = true; } }

elseif( $match_operator == '>' )

{ if( $this->cost > $rule['match_amount'] )

{ $match = true; } }

elseif( $match_operator == '<' )

{ if( $this->cost < $rule['match_amount'] )

{ $match = true; } }

if( $match == true )

{

// set the shipping cost based on the rule operator

// and the rule amount

$rule_operator = $rule['rule_operator'];

if( $rule_operator == '=' )

{ $this->shippingCost = $rule['rule_amount']; }

elseif( $rule_operator == '+' )

{ $this->shippingCost = $this->shippingCost

+ $rule['rule_amount']; }

elseif( $rule_operator == '-' )

{ $this->shippingCost = $this->shippingCost

- $rule['rule_amount']; }

elseif( $rule_operator == '*' )

{ $this->shippingCost = $this->shippingCost

* $rule['rule_amount']; }

elseif( $rule_operator == '/' )

{ $this->shippingCost = $this->shippingCost

/ $rule['rule_amount']; }

}

}

}

}

Tax

There are three main ways to tackle tax costs in an e-commerce environment:

We include tax in our product prices

We assign tax codes to products to separately calculate and display tax costs

We calculate tax based on the location of the buyer

Trang 3

The exact requirement for a particular store depends on the store itself and the laws

applicable in that country or state In some situations we can include the tax for a

product in its price; it doesn't need to be displayed to the customer In others, we

may wish for tax to be shown and calculated for the customer, if they are able to

reclaim this tax (for example UK/EU VAT), and in some states in the US different

states have different taxes depending on the buyer or seller, where some customers

may be taxed, others not, or the tax may be based on the state the seller resides

in themselves

Most situations can be handled by associating products with tax calculations,

so let's focus on that However, we will also discuss how we may implement a

location-based tax system, to charge tax depending on the customer's delivery or

billing address

Separately calculating tax values

We could either have:

Tax included in a product price, and a tax rule calculating how much of the

product's price should be tax

Product costs stored without tax, and associated with their relevant

tax calculations

The main difference to the way tax calculations would need to work and the

shipping costs is that tax costs actually need to be integrated before the basket;

that is, the products themselves should incorporate tax costs

We will look at the second of these two options

This would require:

Products to have a tax code associated with them

A table of tax codes to be stored in our database, along with

calculation details

The tax codes (just a reference for the type of tax; for instance, at the time of writing

in the UK we would have: zero-rated VAT—0%, standard rate VAT—15%, reduced

rate VAT—5%, and different products may have different tax codes associated with

them) would have a calculation value and operation associated with them, similar

to our shipping rules, this allows the framework to easily add/subtract/divide/

multiply the product cost with the calculation value

Trang 4

Field Type Description

order cost and the calculation value, to compute the tax

The following SQL represents this table:

CREATE TABLE `tax_codes` (

`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

`tax_code` varchar(255) NOT NULL,

`calculation_value` DOUBLE NOT NULL,

`calculation_operation` ENUM( '+', '-', '*', '/', '=' ) NOT NULL,

INDEX ( `tax_code` )

) ENGINE = INNODB;

Again, for example, UK standard rate VAT would have a value of 1.15, and an

operation of multiply by

To create a truly flexible tax system for an e-commerce system would involve

a book of its own The simplest methods that we have discussed are relatively

straightforward to implement, especially because we have done some very

similar work with our shipping methods

To think about: Location-based tax costs

In some situations, we may have different taxes applicable depending on the

locations of the buyers and sellers respective to one another This may be something

we would wish to implement Advice from a tax professional is recommended

to determine if this is required for a particular use or implementation of your

framework in a particular store

A look at our basket now at our basket now our basket now

Now that we have implemented shipping costs to our store, our basket has some

changes since we last looked at it:

We have a row in the products table for the shipping costs

The order total includes the shipping costs

Trang 5

Here's a view of our new basket:

Summary

In this chapter, we discussed different ways to approach shipping costs and tax

values for products within our e-commerce store This included:

Creating shipping methods

Creating shipping rules to cap, reduce, wipe, or alter shipping costs based on

the cost of a basket, or have the shipping cost otherwise calculated

Setting shipping costs for each product based on the product and the

shipping method

Setting shipping costs for products based on weights and the

shipping method

How we would introduce tax costs to products

Now that we have looked into shipping and tax in detail, we can look at discount

codes, purchasable voucher codes, and referrals in the next chapter

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

TỪ KHÓA LIÊN QUAN