diff --git a/modules/iq_commerce_ajax_cart/resources/js/ajax-cart.js b/modules/iq_commerce_ajax_cart/resources/js/ajax-cart.js index c2961c4..5964099 100644 --- a/modules/iq_commerce_ajax_cart/resources/js/ajax-cart.js +++ b/modules/iq_commerce_ajax_cart/resources/js/ajax-cart.js @@ -90,18 +90,17 @@ additionalData: additionalData }; $(document).trigger("iq-commerce-cart-refresh-before", [updateData]); - - Object.keys(drupalSettings.progressive_decoupler).filter(function(key){ + Object.keys(drupalSettings.progressive_decoupler).filter(function (key) { return drupalSettings.progressive_decoupler[key].type == 'iq_commerce_ajax_cart_block' - }).forEach(function(blockID){ + }).forEach(function (blockID) { let $blockElement = $('[id^="' + blockID + '"]'); let blockData = drupalSettings.progressive_decoupler[blockID]; - let template = Twig.twig({data: blockData.template}); + let template = Twig.twig({ data: blockData.template }); let pattern = blockData.ui_pattern; if (cartData && cartData[0] && cartData[0].order_items.length) { let $target = $blockElement.find(targetSelector).html(''); - cartData[0].order_items.forEach(function(item){ + cartData[0].order_items.forEach(function (item) { let fieldMapper = new iq_progressive_decoupler_FieldMapper(item, blockData.field_mapping); let $item = $(template.render(fieldMapper.applyMappging())); @@ -116,11 +115,21 @@ $target.append($item); }); - $blockElement.find('[data-total-value]').text(cartData[0].total_price.formatted); + // Adjustment of total price displayed in the Ajax Cart + // For WS-405 Warenkorb Pop-up - Total price Softtrend ticket + //$blockElement.find('[data-total-value]').text(cartData[0].total_price.formatted); + const $prices = $(cartData[0].order_items); + let totalSum = 0; + $prices.each(function () { + let price = parseFloat(this.total_price.number); + totalSum += price; + }); + $blockElement.find('[data-total-value]').text('CHF ' + totalSum.toLocaleString('de-CH', {minimumFractionDigits: 2})); + $blockElement.find('[data-cart-content-holder]').removeClass('loading'); $(document).trigger('ajax-cart-after-block-rendered[' + pattern + ']', $target); } - else{ + else { $blockElement.find('[data-total-value]').text(''); $blockElement.find('[data-cart-content-holder]').addClass('loading'); $blockElement.find(targetSelector).html('
' + $blockElement.find(targetSelector).data('label-empty') + '
');