Function __global->calculate_tax_due
Definitions
sources/ecommerce_tax.php
- Calculate tax that is due based on customer context.Wraps get_tax_using_tax_codes which can do bulk-lookups.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: array
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $details | ?array | No | No | required parameter | N/A | N/A | Map of product details (null: there's no product directly associated). Not strictly needed, only passed for customisation potential. |
| $tax_code | ID_TEXT | No | No | required parameter | N/A | N/A | The tax code. This may be different to the product default, e.g. if a discount is in place. |
| $price | REAL | No | No | required parameter | N/A | N/A | The price |
| $shipping_cost | REAL | No | No | 0 | N/A | N/A | The shipping cost |
| $member_id | ?MEMBER | No | No | Null | N/A | N/A | The member this is for (null: current member) |
| $quantity | integer | No | No | 1 | N/A | N/A | The quantity of items |
Returns
- A tuple: The tax derivation, tax due (including shipping tax), tax tracking ID
- Type: array
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Calculate tax that is due based on customer context.Wraps get_tax_using_tax_codes which can do bulk-lookups.
*
* @param ?array $details Map of product details (null: there's no product directly associated). Not strictly needed, only passed for customisation potential.
* @param ID_TEXT $tax_code The tax code. This may be different to the product default, e.g. if a discount is in place.
* @param REAL $price The price
* @param REAL $shipping_cost The shipping cost
* @param ?MEMBER $member_id The member this is for (null: current member)
* @param integer $quantity The quantity of items
* @return array A tuple: The tax derivation, tax due (including shipping tax), tax tracking ID
*/
function calculate_tax_due(?array $details, string $tax_code, float $price, float $shipping_cost = 0, ?int $member_id = null, int $quantity = 1) : array
* Calculate tax that is due based on customer context.Wraps get_tax_using_tax_codes which can do bulk-lookups.
*
* @param ?array $details Map of product details (null: there's no product directly associated). Not strictly needed, only passed for customisation potential.
* @param ID_TEXT $tax_code The tax code. This may be different to the product default, e.g. if a discount is in place.
* @param REAL $price The price
* @param REAL $shipping_cost The shipping cost
* @param ?MEMBER $member_id The member this is for (null: current member)
* @param integer $quantity The quantity of items
* @return array A tuple: The tax derivation, tax due (including shipping tax), tax tracking ID
*/
function calculate_tax_due(?array $details, string $tax_code, float $price, float $shipping_cost = 0, ?int $member_id = null, int $quantity = 1) : array

