PHP Class CommerceGuys\Tax\Resolver\Context

Includes customer information, store information, and the calculation date.
Show file Open project: commerceguys/tax Class Usage Examples

Protected Properties

Property Type Description
$customerAddress CommerceGuys\Addressing\AddressInterface The customer address.
$customerTaxNumber string The customer's tax number, if provided.
$date DateTime The calculation date.
$storeAddress CommerceGuys\Addressing\AddressInterface The store address.
$storeRegistrations array A list of country codes where the store is additionally registered to collect taxes.

Public Methods

Method Description
__construct ( CommerceGuys\Addressing\AddressInterface $customerAddress, CommerceGuys\Addressing\AddressInterface $storeAddress, string $customerTaxNumber = '', array $storeRegistrations = [], DateTime $date = null ) Creates a Context instance.
getCustomerAddress ( ) : CommerceGuys\Addressing\AddressInterface Gets the customer address.
getCustomerTaxNumber ( ) : string Gets the customer tax number.
getDate ( ) : DateTime Gets the calculation date.
getStoreAddress ( ) : CommerceGuys\Addressing\AddressInterface Gets the store address.
getStoreRegistrations ( ) : array Gets the store registrations.
setCustomerAddress ( CommerceGuys\Addressing\AddressInterface $customerAddress ) Sets the customer address.
setCustomerTaxNumber ( string $customerTaxNumber ) Sets the customer tax number.
setDate ( DateTime $date ) Sets the calculation date.
setStoreAddress ( CommerceGuys\Addressing\AddressInterface $storeAddress ) Sets the store address.
setStoreRegistrations ( array $storeRegistrations ) Sets the store registrations.

Method Details

__construct() public method

Creates a Context instance.
public __construct ( CommerceGuys\Addressing\AddressInterface $customerAddress, CommerceGuys\Addressing\AddressInterface $storeAddress, string $customerTaxNumber = '', array $storeRegistrations = [], DateTime $date = null )
$customerAddress CommerceGuys\Addressing\AddressInterface
$storeAddress CommerceGuys\Addressing\AddressInterface
$customerTaxNumber string
$storeRegistrations array
$date DateTime

getCustomerAddress() public method

Gets the customer address.
public getCustomerAddress ( ) : CommerceGuys\Addressing\AddressInterface
return CommerceGuys\Addressing\AddressInterface The customer address.

getCustomerTaxNumber() public method

Gets the customer tax number.
public getCustomerTaxNumber ( ) : string
return string The customer tax number.

getDate() public method

Gets the calculation date.
public getDate ( ) : DateTime
return DateTime The calculation date.

getStoreAddress() public method

Gets the store address.
public getStoreAddress ( ) : CommerceGuys\Addressing\AddressInterface
return CommerceGuys\Addressing\AddressInterface The store address.

getStoreRegistrations() public method

For example, ['UK'], for a US store registered in the UK to collect EU VAT on digital services.
public getStoreRegistrations ( ) : array
return array An array of country codes where the store is additionally registered to collect taxes.

setCustomerAddress() public method

Sets the customer address.
public setCustomerAddress ( CommerceGuys\Addressing\AddressInterface $customerAddress )
$customerAddress CommerceGuys\Addressing\AddressInterface The customer address.

setCustomerTaxNumber() public method

Sets the customer tax number.
public setCustomerTaxNumber ( string $customerTaxNumber )
$customerTaxNumber string The customer tax number.

setDate() public method

Sets the calculation date.
public setDate ( DateTime $date )
$date DateTime The calculation date.

setStoreAddress() public method

Sets the store address.
public setStoreAddress ( CommerceGuys\Addressing\AddressInterface $storeAddress )
$storeAddress CommerceGuys\Addressing\AddressInterface The store address.

setStoreRegistrations() public method

Sets the store registrations.
public setStoreRegistrations ( array $storeRegistrations )
$storeRegistrations array An array of country codes.

Property Details

$customerAddress protected property

The customer address.
protected AddressInterface,CommerceGuys\Addressing $customerAddress
return CommerceGuys\Addressing\AddressInterface

$customerTaxNumber protected property

The customer's tax number, if provided.
protected string $customerTaxNumber
return string

$date protected property

The calculation date.
protected DateTime $date
return DateTime

$storeAddress protected property

The store address.
protected AddressInterface,CommerceGuys\Addressing $storeAddress
return CommerceGuys\Addressing\AddressInterface

$storeRegistrations protected property

A list of country codes where the store is additionally registered to collect taxes.
protected array $storeRegistrations
return array