Hey,
I wasn't the one that started working on this project and now I started but I'm a bit lost in this part, I don't know if it is a bug or something that the previews developers did.
The problem is that is all alright if the user is in the store without login done, but when the user do login the subtotal on the minicart isn't right, I think it changed to the one without the taxes plus some functionalities in the cart page does not work as well like some dropdown blocks that calculate the shipping for example.
What can be causing this? I can see some parts working with the isLoggedIn() but I can't understand what's doing that.
Update: The subtotal showing on the header in the mais page with the language "/pt_pt/" shows a fixed value , in the categories and products it show's without tax and in checkout it is correct.
I'm posting here the header where it shows the "mini-cart-subtotal" that is wrong when the user is logged in. I think the problem it's the same in every page
<?php /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ // @codingStandardsIgnoreFile /** * @var \Magento\Theme\Block\Html\Header $block */ ?> <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManager->create('Magento\Customer\Model\Session'); if ($customerSession->isLoggedIn()) { //echo '=============>'; ?> <?php }else{ ?> <style> /*div#checkoutSteps .col-mp.mp-4.mp-sm-6.mp-xs-12:first-child { margin-top: 67px !important; } .opc-wrapper.one-step-checkout-wrapper { margin-top: -56px !important; }*/ </style> <?php } ?> <header class="page-header alothemes"> <div class="header"> <div class="header-top"> <div class="welcom_meg"> <div class="container"> <div class="row"> <div class="top-left col-md-4 col-sm-4 col-xs-12"> <?php //echo $this->getChildHtml('welcometop'); ?> <div class="settting-switcher"> <div class="lan-switcher"><?php echo $this->getChildHtml('store_language'); ?></div> <!--<div class="dropdown-toggle toggle-tab outside-close"> <div class="text-setting"><?php echo __('Links'); ?></div> </div> <div class="dropdown-switcher toggle-content"> <?php echo $this->getChildHtml('currency'); ?> <?php echo $this->getChildHtml('store_language'); ?> </div>--> </div> </div> <div class="top-left col-md-4 col-sm-4 col-xs-12"> <?php echo $this->getChildHtml('welcometop'); ?> </div> <div class="top-right col-md-4 col-sm-4 col-xs-12"> <div class="header-setting"> <div class="top-links"> <?php echo $this->getChildHtml('header.links'); ?> </div> </div> </div> </div> </div> </div> </div> <div class="header-content"> <div class="container"> <div class="row"> <!--<div class="content-seach col-md-4 col-sm-12 col-xs-12"> <div class="search-area header-search"> <?php //echo $this->getChildHtml('top.search'); ?> </div> </div>--> <div class="content-logo col-md-3 col-sm-12 col-xs-12"> <div class="header-logo"> <?php echo $this->getChildHtml('logo'); ?> </div> </div> <div class="col-md-5"></div> <div class="content-cart menu-mobile col-md-4 col-sm-12 col-xs-12"> <div class="search-area header-search"> <?php //echo $this->getChildHtml('top.search'); ?> <a href="Javascript:Void(0);" id="sear"><i class="fs1" data-icon="U" aria-hidden="true"></i></a> <div id="musicinfo"> <?php echo $this->getChildHtml('top.search'); ?> </div> </div> <div class="wis_lis"><a href="<?php echo $this->getUrl('wishlist') ?>"><i class="icon-heart icons"></i></a></div> <span data-action="toggle-nav" class="action nav-toggle"><span><?php /* @escapeNotVerified */ echo __('Toggle Nav') ?></span></span> <?php echo $this->getChildHtml('minicart'); ?> <?php $objmanager = \Magento\Framework\App\ObjectManager::getInstance(); $session = $objmanager->get("Magento\Checkout\Model\Session"); $quote =$session->getQuote(); $total = $quote->getSubtotal(); //get total price $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); $formattedPrice = $priceHelper->currency($total, true, false); ?> <span id="mini-cart-subtotal"><?php echo $formattedPrice; ?></span> </div> </div> </div> </div> <div class="header-bottom header-sticker"> <div class="container"> <div class="row"> <div class="col-lg-12"> <?php echo $this->getChildHtml('navigation.sections'); ?> <!-- <div class="search-area header-search vh_gts"> <?php //echo $this->getChildHtml('top.search'); ?> <a href="Javascript:Void(0);" id="sear2"><i class="fs1" data-icon="U" aria-hidden="true"></i></a> <div id="musicinfo2"> <?php //echo $this->getChildHtml('top.search'); ?>hi </div> --> </div> </div> </div> </div> </div> </header> <script type="text/javascript"> require(['jquery'], function($){ var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); if (isChrome){ jQuery('body').addClass('is_chrome') ; } //alert("You are using Chrome!"); jQuery(window).scroll(function() { var scroll = jQuery(window).scrollTop(); if (scroll >= 50) { jQuery(".menu-mobile").addClass("stick"); } else { jQuery(".menu-mobile").removeClass("stick"); } }); }); </script> <script> require(['jquery'], function($){ $(document).ready(function() { //alert('hiiii'); $( ".minicart-wrapper" ).append( $( "#mini-cart-subtotal" ) ); $("#sear").click(function() { //alert('hiiiii'); $("#musicinfo").fadeToggle(); }); }); }); </script> <script> require(['jquery'], function($){ $("#sear2").click(function() { //alert('hiiiii'); $("#musicinfo2").fadeToggle(); }); }); </script> <script> require(['jquery'], function($){ $(document).ready(function(){ //alert('hiiiii'); //$( ".menu-search" ).append( $( ".search-area" ) ); //$( ".menu-cart" ).append( $( ".minicart-wrapper" ) ); $( ".logout_warper" ).append( $( ".customer-account-logoutsuccess .page-title-wrapper" ) ); $('.compare').css('display','none'); }); }); </script> <script type="text/javascript"> require(['jquery'], function ($) { $(document).ajaxComplete(function (event, xhr, settings) { if (settings.url.indexOf("customer/section/load/?sections=cart") > 0) { cartObj = xhr.responseJSON; //console.log(cartObj); //console.log('ex tax: ' + cartObj.cart.subtotal_excl_tax); //console.log('inc tax: ' + cartObj.cart.subtotal_incl_tax); //console.log('subtotal: ' + cartObj.cart.subtotal); $( "#mini-cart-subtotal" ).html( cartObj.cart.subtotal ); } }); }); </script> <?php $om = \Magento\Framework\App\ObjectManager::getInstance(); $context = $om->get('Magento\Framework\App\Http\Context'); $isLoggedIn = $context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); if($isLoggedIn){ $cust_data = $context->getData(); if($cust_data['customer_group'] == 2){ ?> <script> require(['jquery'], function($){ $(document).ready(function(){ setInterval(function(){ $("input.cart-item-qty").prop("disabled", true); }, 3000); }); }); </script> <?php } } ?> <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $storeCode = $storeManager->getStore()->getCode(); if($storeCode == 'es_es'){ ?> <script> require(['jquery'], function($){ $(document).ready(function() { setInterval(function(){ $(".osc-newsletter.field.choice span").text("Subscríbe nuestro boletín"); if($('#phone_number').length > 0){ $('#phone_number').attr('placeholder','Número de teléfono móvil'); } }, 500); }); }); </script> <?php }else if($storeCode == 'pt_pt'){ ?> <script> require(['jquery'], function($){ $(document).ready(function() { setInterval(function(){ $(".osc-newsletter.field.choice span").text("Registar na newsletter"); if($('#phone_number').length > 0){ $('#phone_number').attr('placeholder','Número de telefone'); } $('.checkout-comment-block label').html('Comentários'); }, 500); }); }); </script> <?php }else{ ?> <script> require(['jquery'], function($){ $(document).ready(function() { setInterval(function(){ if($('#phone_number').length > 0){ $('#phone_number').attr('placeholder','Mobile Number'); } }, 500); }); }); </script> <?php } ?> <script> require(['jquery'], function($){ $(document).ready(function() { var interval = setInterval(function(){ if($('#billing-address-same-as-shipping').length > 0){ if(!$('#billing-address-same-as-shipping').attr('checked')){ $('#billing-address-same-as-shipping').trigger('click'); clearInterval(interval); //alert($('#billing-address-same-as-shipping').attr('checked').val()); } } }, 500); var interval1 = setInterval(function(){ if($('#osc-place-order-newsletter').length > 0){ if($('#osc-place-order-newsletter').attr('checked')){ $('#osc-place-order-newsletter').trigger('click'); console.log($('#osc-place-order-newsletter').attr('checked')); clearInterval(interval1); } } }, 500); }); }); </script>
Thanks!