Fixed: Code review changes and issues found in unit testing

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
shazar rahman
2026-09-18 13:33:26 +05:30
parent 3842071478
commit 37ff17ec56
5 changed files with 55 additions and 11 deletions

View File

@@ -218,11 +218,14 @@ class Blockcart extends Module
$tax_cost = 0;
$tourismTaxCost = Tools::displayPrice(0, $currency);
$totalTaxesCost = Tools::displayPrice(0, $currency);
if ($useTax && $useTax) {
$totalToPayWithoutTaxes = $params['cart']->getOrderTotal(false);
$tax_cost = Tools::displayPrice(($totalToPay - $totalToPayWithoutTaxes) - $tourismTax, $currency);
$tourismTaxCost = Tools::displayPrice($tourismTax, $currency);
$totalTaxesCost = Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency);
}
$showTourismTaxSeparately = (bool) Configuration::get('QLO_TOURISM_TAX_SHOW_SEPARATE');
// The cart content is altered for display
$orderProcess = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order';
foreach ($cart_rules as &$cart_rule) {
@@ -439,6 +442,8 @@ class Blockcart extends Module
'tax_cost' => $tax_cost,
'tourism_tax_cost' => $tourismTaxCost,
'tourism_tax' => $tourismTax,
'total_taxes_cost' => $totalTaxesCost,
'show_tourism_tax_separately' => $showTourismTaxSeparately,
'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency),
'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($useTax, Cart::ONLY_PRODUCTS), $currency),
'room_total' => ($totalRoomsPrice + $totalAdditionalServicesWithAutoAddPrice + $totalAdditionalServicesWithoutAutoAddPrice),

View File

@@ -137,7 +137,7 @@
{/if} --><!-- commented by webkul unnecessary data -->
{block name='blockcart_shopping_cart_total_tax'}
{if $show_tax && $use_tax}
<div class="cart-prices-line">
<div class="cart-prices-line ajax_cart_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<span class="price cart_block_tax_cost ajax_cart_tax_cost">{$tax_cost}</span>
<span>{l s='Room and Service Tax' mod='blockcart'}</span>
</div>
@@ -145,12 +145,20 @@
{/block}
{block name='blockcart_shopping_cart_total_tourism_tax'}
{if $show_tax && $use_tax}
<div class="cart-prices-line ajax_cart_tourism_tax_line"{if !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<div class="cart-prices-line ajax_cart_tourism_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<span class="price cart_block_tourism_tax_cost ajax_cart_tourism_tax_cost">{$tourism_tax_cost}</span>
<span>{l s='Total Tourism Tax' mod='blockcart'}</span>
</div>
{/if}
{/block}
{block name='blockcart_shopping_cart_total_taxes_combined'}
{if $show_tax && $use_tax}
<div class="cart-prices-line ajax_cart_total_taxes_line"{if isset($show_tourism_tax_separately) && $show_tourism_tax_separately && isset($tourism_tax) && $tourism_tax > 0} style="display:none"{/if}>
<span class="price cart_block_total_taxes_cost ajax_cart_total_taxes_cost">{$total_taxes_cost}</span>
<span>{l s='Total Taxes' mod='blockcart'}</span>
</div>
{/if}
{/block}
{block name='blockcart_shopping_cart_total_convenience_fee'}
{if isset($total_convenience_fee)}
<div class="cart-prices-line">
@@ -352,7 +360,7 @@
{/block}
{block name='blockcart_layer_cart_total_tax'}
{if $show_tax && $use_tax}
<div class="layer_cart_row">
<div class="layer_cart_row ajax_cart_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<strong class="dark">{l s='Room and Service Tax' mod='blockcart'}</strong>
<span class="price cart_block_tax_cost ajax_cart_tax_cost pull-right">{$tax_cost}</span>
</div>
@@ -360,12 +368,20 @@
{/block}
{block name='blockcart_layer_cart_total_tourism_tax'}
{if $show_tax && $use_tax}
<div class="layer_cart_row ajax_cart_tourism_tax_line"{if !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<div class="layer_cart_row ajax_cart_tourism_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<strong class="dark">{l s='Total Tourism Tax' mod='blockcart'}</strong>
<span class="price cart_block_tourism_tax_cost ajax_cart_tourism_tax_cost pull-right">{$tourism_tax_cost}</span>
</div>
{/if}
{/block}
{block name='blockcart_layer_cart_total_taxes_combined'}
{if $show_tax && $use_tax}
<div class="layer_cart_row ajax_cart_total_taxes_line"{if isset($show_tourism_tax_separately) && $show_tourism_tax_separately && isset($tourism_tax) && $tourism_tax > 0} style="display:none"{/if}>
<strong class="dark">{l s='Total Taxes' mod='blockcart'}</strong>
<span class="price cart_block_total_taxes_cost ajax_cart_total_taxes_cost pull-right">{$total_taxes_cost}</span>
</div>
{/if}
{/block}
{block name='blockcart_layer_cart_total_price'}
<div class="layer_cart_row">
<strong class="dark">

View File

@@ -229,6 +229,7 @@
.cart_block .cart_block_shipping_cost,
.cart_block .cart_block_tax_cost,
.cart_block .cart_block_tourism_tax_cost,
.cart_block .cart_block_total_taxes_cost,
.cart_block .cart_block_total,
.cart_block .cart_block_wrapping_cost,
.cart_block .cart_block_convenience_fee {

View File

@@ -1327,10 +1327,13 @@ var ajaxCart = {
$('.ajax_cart_tax_cost').text(jsonData.tax_cost);
$('.ajax_cart_tourism_tax_cost').text(jsonData.tourism_tax_cost);
if (parseFloat(jsonData.tourism_tax) > 0) {
$('.ajax_cart_tourism_tax_line').show();
$('.ajax_cart_total_taxes_cost').text(jsonData.total_taxes_cost);
if (jsonData.show_tourism_tax_separately && parseFloat(jsonData.tourism_tax) > 0) {
$('.ajax_cart_tax_line, .ajax_cart_tourism_tax_line').show();
$('.ajax_cart_total_taxes_line').hide();
} else {
$('.ajax_cart_tourism_tax_line').hide();
$('.ajax_cart_tax_line, .ajax_cart_tourism_tax_line').hide();
$('.ajax_cart_total_taxes_line').show();
}
$('.cart_block_wrapping_cost').text(jsonData.wrapping_cost);

View File

@@ -137,7 +137,8 @@
{/if} --><!-- commented by webkul unnecessary data -->
{block name='blockcart_shopping_cart_total_tax'}
{if $show_tax && $use_tax}
<div class="cart-prices-line">
{* Always rendered — see blockcart_shopping_cart_total_tourism_tax below for why a value-gated {if} would break on later AJAX-only cart updates. *}
<div class="cart-prices-line ajax_cart_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<span class="price cart_block_tax_cost ajax_cart_tax_cost">{$tax_cost}</span>
<span>{l s='Room and Service Tax' mod='blockcart'}</span>
</div>
@@ -145,12 +146,20 @@
{/block}
{block name='blockcart_shopping_cart_total_tourism_tax'}
{if $show_tax && $use_tax}
<div class="cart-prices-line ajax_cart_tourism_tax_line"{if !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<div class="cart-prices-line ajax_cart_tourism_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<span class="price cart_block_tourism_tax_cost ajax_cart_tourism_tax_cost">{$tourism_tax_cost}</span>
<span>{l s='Total Tourism Tax' mod='blockcart'}</span>
</div>
{/if}
{/block}
{block name='blockcart_shopping_cart_total_taxes_combined'}
{if $show_tax && $use_tax}
<div class="cart-prices-line ajax_cart_total_taxes_line"{if isset($show_tourism_tax_separately) && $show_tourism_tax_separately && isset($tourism_tax) && $tourism_tax > 0} style="display:none"{/if}>
<span class="price cart_block_total_taxes_cost ajax_cart_total_taxes_cost">{$total_taxes_cost}</span>
<span>{l s='Total Taxes' mod='blockcart'}</span>
</div>
{/if}
{/block}
{block name='blockcart_shopping_cart_total_convenience_fee'}
{if isset($total_convenience_fee) && $total_convenience_fee}
<div class="cart-prices-line">
@@ -352,7 +361,9 @@
{/block}
{block name='blockcart_layer_cart_total_tax'}
{if $show_tax && $use_tax}
<div class="layer_cart_row">
{* Always rendered — see the matching dropdown block above for why a value-gated
{if} would break on later AJAX-only cart updates. *}
<div class="layer_cart_row ajax_cart_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<strong class="dark">{l s='Room and Service Tax' mod='blockcart'}</strong>
<span class="price cart_block_tax_cost ajax_cart_tax_cost pull-right">{$tax_cost}</span>
</div>
@@ -362,12 +373,20 @@
{if $show_tax && $use_tax}
{* Always rendered — see the matching dropdown block above for why a value-gated
{if} would break on later AJAX-only cart updates. *}
<div class="layer_cart_row ajax_cart_tourism_tax_line"{if !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<div class="layer_cart_row ajax_cart_tourism_tax_line"{if !isset($show_tourism_tax_separately) || !$show_tourism_tax_separately || !isset($tourism_tax) || $tourism_tax <= 0} style="display:none"{/if}>
<strong class="dark">{l s='Total Tourism Tax' mod='blockcart'}</strong>
<span class="price cart_block_tourism_tax_cost ajax_cart_tourism_tax_cost pull-right">{$tourism_tax_cost}</span>
</div>
{/if}
{/block}
{block name='blockcart_layer_cart_total_taxes_combined'}
{if $show_tax && $use_tax}
<div class="layer_cart_row ajax_cart_total_taxes_line"{if isset($show_tourism_tax_separately) && $show_tourism_tax_separately && isset($tourism_tax) && $tourism_tax > 0} style="display:none"{/if}>
<strong class="dark">{l s='Total Taxes' mod='blockcart'}</strong>
<span class="price cart_block_total_taxes_cost ajax_cart_total_taxes_cost pull-right">{$total_taxes_cost}</span>
</div>
{/if}
{/block}
{block name='blockcart_layer_cart_total_price'}
<div class="layer_cart_row">
<strong class="dark">