Permalink
Browse files

Fix Ecommerce Taxes when total is with 5+ digits

  • Loading branch information...
sebastienheraud committed Dec 4, 2018
1 parent 1d8350a commit 927e24ea09a673c2fed470a1c0d76d5265ba311e
Showing with 7 additions and 7 deletions.
  1. +7 −7 libraries/cms/cck/ecommerce/tax.php
@@ -93,7 +93,7 @@ public static function apply( $type, &$total, $items, $params = array() )
switch ( $t->tax ) {
case 'plus':
$tax = (float)number_format( $t->tax_amount, 2 );
$tax = (float)number_format( $t->tax_amount, 2, '.', '' );
if ( $params['target'] == 'product' || $params['target'] == 'product2' ) {
$tax = $tax * $quantity;
@@ -112,16 +112,16 @@ public static function apply( $type, &$total, $items, $params = array() )
case 'percentage':
if ( $params['target'] == 'product2' ) {
if ( isset( $params['target_id'] ) && $params['target_id'] && $params['source'] == 'item' && count( $items ) && isset( $items[$params['target_id']] ) ) {
$tax = (float)number_format( $items[$params['target_id']]['_']->price * $t->tax_amount / 100, 2 );
$tax = (float)number_format( $items[$params['target_id']]['_']->price * $t->tax_amount / 100, 2, '.', '' );
// if ( isset( $params['apply_quantity'] ) && $params['apply_quantity'] ) {
$tax = $tax * $quantity;
// }
} else {
$tax = (float)number_format( $total * $t->tax_amount / 100, 2 );
$tax = (float)number_format( $total * $t->tax_amount / 100, 2, '.', '' );
}
} else {
$tax = (float)number_format( $total * $t->tax_amount / 100, 2 );
$tax = (float)number_format( $total * $t->tax_amount / 100, 2, '.', '' );
}
$res += $tax;
@@ -151,15 +151,15 @@ public static function apply( $type, &$total, $items, $params = array() )
continue;
}
$tax = (float)number_format( $item->tax, 2 );
$tax = (float)number_format( $item->tax, 2, '.', '' );
$tax = $tax * $quantity;
} else {
if ( count( $items ) ) {
if ( isset( $params['target_id'] ) && $params['target_id'] ) {
if ( empty( $items[$params['target_id']]->price ) ) {
continue;
}
$tax = (float)number_format( $items[$params['target_id']]->tax, 2 );
$tax = (float)number_format( $items[$params['target_id']]->tax, 2, '.', '' );
$tax = $tax * $quantity;
} else {
foreach ( $items as $item_list ) {
@@ -190,7 +190,7 @@ public static function apply( $type, &$total, $items, $params = array() )
}
}
if ( isset( $item->tax ) && $item->tax != '' ) {
$amount = (float)number_format( $item->tax, 2 );
$amount = (float)number_format( $item->tax, 2, '.', '' );
if ( isset( $item->quantity ) && $item->quantity ) {
$qty = $item->quantity;

0 comments on commit 927e24e

Please sign in to comment.