|
Server IP : 10.131.40.8 / Your IP : 216.73.216.37 Web Server : Apache System : Linux webd008.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : ludmqhh ( 137773) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/ludmqhh/www/hotel-forum/wp-content/plugins/wp-hotelier/includes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* Hotelier Tax Functions.
*
* @author Benito Lopez <hello@lopezb.com>
* @category Core
* @package Hotelier/Functions
* @version 1.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Check if tax is enabled.
*
* @return bool
*/
function htl_is_tax_enabled() {
$tax_enabled = htl_get_option( 'tax_enabled', false );
return apply_filters( 'hotelier_is_tax_enabled', $tax_enabled );
}
/**
* Check if tax is enabled on deposits.
*
* @return bool
*/
function htl_is_deposit_tax_enabled() {
$tax_enabled = htl_get_option( 'tax_in_deposit', false );
return apply_filters( 'hotelier_is_deposit_tax_enabled', $tax_enabled );
}
/**
* Get tax rate.
*
* @return float
*/
function htl_get_tax_rate() {
$tax_rate = (float) htl_get_option( 'tax_rate', 0 );
return apply_filters( 'hotelier_get_tax_rate', $tax_rate );
}
/**
* Calculate tax.
*
* Taxes are round up to the next cent. A filter is
* provided for developers.
*
* @param int $amount Amount without tax.
* @return int
*/
function htl_calculate_tax( $amount ) {
$tax_enabled = htl_is_tax_enabled();
// Return early if tax is not enabled
if ( ! $tax_enabled ) {
return 0;
}
$tax_rate = htl_get_tax_rate();
// Return early if tax rate is 0
if ( ! $tax_rate ) {
return 0;
}
$calculated_tax = ceil( $amount * ( $tax_rate / 100 ) );
$calculated_tax = apply_filters( 'hotelier_calulate_tax', $calculated_tax, $amount, $tax_rate );
return absint( $calculated_tax );
}
