Function
Tax classes functions
On this page
Functions for tax classes: rates per category or menu item and optional tax codes.
7 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.
rpress_tax_classes_editor_render()#
Prints the tax classes table in Settings > Taxes.
Lists the Standard class as read-only and the other classes as editable rows. Hooked to rpress_tax_classes_editor.
rpress_tax_classes_editor_render()
Note: Echoes output instead of returning it.
Internal. Defined in includes/features/tax-classes/loader.php, line 58.
rpress_tax_class_clean_row()#
Normalizes one posted tax class row.
The rate is clamped between 0 and 100 and a comma decimal separator is accepted. The code is sanitized as text.
rpress_tax_class_clean_row( $name, $row )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$name | string | Required | Class name. |
$row | array | Required | Posted row with rate and code. |
Returns array: Array with name, rate (float percent) and code.
Internal. Defined in includes/features/tax-classes/loader.php, line 220.
rpress_tax_class_select()#
Returns the markup of a tax class dropdown.
Lists every class from rpress_get_tax_classes() with its rate, preceded by an empty option labelled with the inherit text. The select's id equals its name.
rpress_tax_class_select( $name, $selected, $inherit )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$name | string | Required | Field name. |
$selected | string | Required | Selected class slug; an empty string selects the inherit option. |
$inherit | string | Required | Label of the empty option. |
Returns string: Escaped select HTML.
Internal. Defined in includes/features/tax-classes/loader.php, line 237.
rpress_save_term_tax_class()#
Saves the tax class of a food category.
Hooked to created_food-category and edited_food-category. Needs the rpress_term_tax_class nonce and the manage_product_terms or manage_categories capability. Standard or an unknown class removes the _rpress_tax_class term meta.
rpress_save_term_tax_class( $term_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$term_id | int | Required | Term ID. |
Internal. Defined in includes/features/tax-classes/loader.php, line 285.
rpress_get_order_tax_breakdown()#
Returns the per-class tax rows stored for an order.
Reads the _rpress_tax_breakdown post meta. Returns an empty array for single-rate orders, that is when fewer than two classes were stored.
rpress_get_order_tax_breakdown( $payment_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order (payment) ID. |
Returns array: Rows keyed by class slug, each with name, rate, code and tax; empty array for single-rate orders.
Example
foreach ( rpress_get_order_tax_breakdown( $payment_id ) as $slug => $row ) {
echo esc_html( rpress_tax_breakdown_label( $row ) );
}
Defined in includes/features/tax-classes/loader.php, line 348.
rpress_tax_breakdown_label()#
Returns the display label of one tax breakdown row.
Combines the tax name, class name and rate, for example GST Beverages 18%, and appends the tax code in brackets when the row has one.
rpress_tax_breakdown_label( $row )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$row | array | Required | Breakdown row with name, rate and optionally code. |
Returns string: Label text (unescaped).
Defined in includes/features/tax-classes/loader.php, line 359.
rpress_render_order_tax_breakdown()#
Prints the per-class tax rows for an order.
Hooked to rpress_receipt_after_tax_row and rpress_admin_order_after_tax_row. Prints nothing for single-rate orders.
rpress_render_order_tax_breakdown( $payment_id, $context = 'receipt' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order ID. |
$context | string | 'receipt' | Either receipt or admin; controls the markup. |
Note: Echoes output instead of returning it.
Internal. Defined in includes/features/tax-classes/loader.php, line 398.
