本文整理汇总了PHP中Shopp::taxrates方法的典型用法代码示例。如果您正苦于以下问题:PHP Shopp::taxrates方法的具体用法?PHP Shopp::taxrates怎么用?PHP Shopp::taxrates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shopp
的用法示例。
在下文中一共展示了Shopp::taxrates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _taxed
/**
* Helper to apply or exclude taxes from a single amount based on inclusive tax settings and the tax option
*
* @author Jonathan Davis
* @since 1.3
*
* @param float $amount The amount to add taxes to, or exclude taxes from
* @param ShoppProduct $O The product to get properties from
* @param boolean $istaxed Whether the amount can be taxed
* @param boolean $taxoption The Theme API tax option given the the tag
* @param array $taxrates A list of taxrates that apply to the product and amount
* @return float The amount with tax added or tax excluded
**/
private static function _taxed($amount, ShoppProduct $O, $istaxed, $taxoption = null, array $taxrates = array())
{
if (!$istaxed) {
return $amount;
}
if (empty($taxrates)) {
$taxrates = Shopp::taxrates($O);
}
if (isset($taxoption)) {
$taxoption = Shopp::str_true($taxoption);
}
$inclusivetax = self::_inclusive_taxes($O);
if ($inclusivetax) {
$adjustment = ShoppTax::adjustment($taxrates);
if (1 != $adjustment && false !== $taxoption) {
// Only adjust when taxes are not excluded @see #3041
return (double) ($amount / $adjustment);
}
}
// Handle inclusive/exclusive tax presentation options (product editor setting or api option)
// If the 'taxes' option is specified and the item either has inclusive taxes that apply,
// or the 'taxes' option is forced on (but not both) then handle taxes by either adding or excluding taxes
// This is an exclusive or known as XOR, the lesser known brother of Thor that gets left out of the family get togethers
if (isset($taxoption) && $inclusivetax ^ $taxoption) {
if ($taxoption) {
return ShoppTax::calculate($taxrates, (double) $amount);
} else {
return ShoppTax::exclusive($taxrates, (double) $amount);
}
}
return $amount;
}