Italian (Italy)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Taxes  >  Load Operators

do_action_ref_array( 'vikrestaurants_load_tax_operators', array &$operators )

Fires while fetching all the supported taxes operators.


Description

Trigger hook to allow external plugins to support custom operations.

New operations have to be appended to the given associative array. The key of the array is the unique ID of the operation, the value is a readable name to display.

All the registered operators will be reported within the Math Operation dropdown, under the management page of a new tax rule.

Here's a list of operators supported by default:

  • add - sums the tax amount to the total cost (also known as excluded taxes);
  • sub - subtracts the tax amount from the total cost;
  • vat - separates the tax amount from the total cost (also known as inclusive taxes).

Parameters

&$operators

(array)  An array of operators.


Example

The example below adds support for a new operator that applies the VAT only to European customers that do not have a valid VAT Number.

/** 
 * Trigger hook to allow external plugins to support custom operations.
 * New operations have to be appended to the given associative array.
 * The key of the array is the unique ID of the operation, the value is
 * a readable name to display.
 *
 * @param  array    &$operators  An array of supported operators.
 */
add_action('vikrestaurants_load_tax_operators', function(&$operators) {
    // the key is the operator alias, the value is the name that appears within the dropdown
    $operators['euvat'] = __('European VAT', 'myplugin');
});

Changelog

Version Description
1.3 Introduced.
Ultimo aggiornamento: 2023-12-19
Utile?
Potrebbe interessarti: