calculate_tax

The WooCommerce Sisow Mastercard calculate tax function.

Description

calculate_tax( $settings, $charge ); 

Parameters (2)

0. $settings
The settings.
1. $charge
The charge.

Usage

  1. if ( !function_exists( 'calculate_tax' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-sisow-mastercard/sisow/base.php'; 
  3.  
  4. // The settings. 
  5. $settings = null; 
  6.  
  7. // The charge. 
  8. $charge = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = calculate_tax($settings, $charge); 
  12.  

Defined (1)

The function is defined in the following location(s).

/sisow/base.php  
  1. function calculate_tax($settings, $charge) { 
  2. $amount = 0; 
  3.  
  4. $prices_include_tax = get_option('woocommerce_prices_include_tax') == 'yes' ? true : false; 
  5.  
  6. $_tax = new WC_Tax(); 
  7. $tax_rates = $_tax->get_shop_base_rate($settings['paymentfeetax']); 
  8. $taxes = $_tax->calc_tax($charge, $tax_rates, $prices_include_tax); 
  9. $amount = $_tax->get_tax_total($taxes); 
  10.  
  11. return $amount;