Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:cache:litemage:troubleshooting:add_to_cart_but_show_as_empty_next_page [2017/05/03 18:11]
Jackson Zhang created
litespeed_wiki:cache:litemage:troubleshooting:add_to_cart_but_show_as_empty_next_page [2017/05/03 19:53]
Michael Alegre Edited for grammer and improved formatting.
Line 1: Line 1:
-===== Add item to cart but cart shows as empty when moving to next page ===== +====== Add item to cart but cart shows as empty when moving to next page ======
-LiteMage is working and it's caching pages for logged in users. However, once someone adds something to their cart and then moves on to the next page, the cart shows up as empty at the top right of the page. +
  
-Looks like header top links are not properly hole punchedVerified through ​+==== Symptoms ==== 
 +  * Cart icon shows up as empty after adding an item and navigating to another page.
  
-  https://www.domain.com/?​LITEMAGE_DEBUG=SHOWHOLES ​+==== Cause ==== 
 +Header toplinks are not being properly hole punched. This can be verified by following our [[litespeed_wiki:cache:​litemage:​troubleshooting:​checking-hole-punching|How to check if ESI block holes are being properly punched]] page.
  
-and confirmed no hole punch. 
  
 +==== Solution ====
 Checking the config - design from Magento Admin, it uses default theme_revamp. Checking the config - design from Magento Admin, it uses default theme_revamp.
  
-In header.phtml:​+In header.phtml ​we see the following:
  
-  ​<div class="​row">​+<​code>​ 
 +<div class="​row">​
   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​
-  ​<div class="​top-sticky-text">​ +    ​<div class="​top-sticky-text">​ 
-  <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​header_sticky_block'​)->​toHtml();​ ?> +      <?php echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​header_sticky_block'​)->​toHtml();​ ?> 
-  </​div>​+    </​div>​
   </​div>​   </​div>​
   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​
-  ​<div class="​top-links">​ +    ​<div class="​top-links">​ 
-  <ul class="​top-links-list">​ +      <ul class="​top-links-list">​ 
-  <?php if ($this->​helper('​customer'​)->​isLoggedIn()):​ ?> +        <?php if ($this->​helper('​customer'​)->​isLoggedIn()):​ ?> 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​logout'​);​ ?>"><​i class="​account-icon"></​i>​Logout</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​logout'​);​ ?>"><​i class="​account-icon"></​i>​Logout</​a></​li>​ 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account'​);​ ?>"><​i class="​signup-icon"></​i>​My Account</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account'​);​ ?>"><​i class="​signup-icon"></​i>​My Account</​a></​li>​ 
-  <?php else: ?> +        <?php else: ?> 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​login'​);​ ?>"><​i class="​account-icon"></​i>​Login</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​login'​);​ ?>"><​i class="​account-icon"></​i>​Login</​a></​li>​ 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​create'​);​ ?>"><​i class="​signup-icon"></​i>​Sign up</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​create'​);​ ?>"><​i class="​signup-icon"></​i>​Sign up</​a></​li>​ 
-  <?php endif ?> +        <?php endif ?> 
-  <​li><​a href="<?​php echo Mage::​helper('​checkout/​url'​)->​getCheckoutUrl();​ ?>"><​i class="​checkout-icon"></​i>​Checkout</​a></​li>​ +        <​li><​a href="<?​php echo Mage::​helper('​checkout/​url'​)->​getCheckoutUrl();​ ?>"><​i class="​checkout-icon"></​i>​Checkout</​a></​li>​ 
-  <li class="​bulk-link">​ +        <li class="​bulk-link">​ 
-  <a href="<?​php echo $this->​getUrl('​quickshopping'​);​ ?>"><​i class="​bulkpro-icon"></​i>​Quick Shop</​a>​ +          <a href="<?​php echo $this->​getUrl('​quickshopping'​);​ ?>"><​i class="​bulkpro-icon"></​i>​Quick Shop</​a>​ 
-  </​li>​ +        </​li>​ 
-  <li class="​search-cart-cart-btn">​ +        <li class="​search-cart-cart-btn">​ 
-  <?php $_cartQty = Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty()?​Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty():'​0';​ ?> +          <?php $_cartQty = Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty()?​Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty():'​0';​ ?> 
-  <div id="​cart-main"​ class="​search-cart cart-btn <?php if($_cartQty != 0) echo '​color-red';​ ?>">​ +          <div id="​cart-main"​ class="​search-cart cart-btn <?php if($_cartQty != 0) echo '​color-red';​ ?>">​ 
-  <div class="​div_link-cart">​ +            <div class="​div_link-cart">​ 
-  <div class="​div_link-cart_inner"><?​php echo $this->​__('<​a href="​%s"​ id="​topcartlink"​ class="​top-cart"><​i class="​cart-icon"></​i><​span class="​item-cart">​ %s </​span>​items </​a>',​ $this->​getUrl('​checkout/​cart'​),​$_cartQty) ?> +              <div class="​div_link-cart_inner"><?​php echo $this->​__('<​a href="​%s"​ id="​topcartlink"​ class="​top-cart"><​i class="​cart-icon"></​i><​span class="​item-cart">​ %s </​span>​items </​a>',​ $this->​getUrl('​checkout/​cart'​),​$_cartQty) ?> 
-  <div id="​top_cart_sidebar"​ style="​display:​ none"><?​php echo $this->​getChildHtml('​em0050_cart_sidebar_top'​);?>​ +                <div id="​top_cart_sidebar"​ style="​display:​ none"><?​php echo $this->​getChildHtml('​em0050_cart_sidebar_top'​);?>​ 
-  </​div>​ +                </​div>​ 
-  </​div>​ +              </​div>​ 
-  </​div>​ +            </​div>​ 
-  </​div>​ +          </​div>​ 
-  </​li>​ +        </​li>​ 
-  </​ul>​ +      </​ul>​ 
-  </​div>​ +    </​div>​
-  ​</​div>​+
   </​div>​   </​div>​
 +</​div>​
 +</​code>​
 +
 +Create a new template ''​toprow.phtml''​ in ''/​home/​user1/​public_html/​app/​design/​frontend/​default/​theme_revamp/​template/​page/​html''​ with the following content:
   ​   ​
-Create a new template toprow.phtml at  +<​code>​ 
-  /​home/​user1/​public_html/​app/​design/​frontend/​default/​theme_revamp/​template/​page/​html +<div class="​row">​
-   +
-  ​<div class="​row">​+
   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​
-  ​<div class="​top-sticky-text">​ +    ​<div class="​top-sticky-text">​ 
-  <?php  +      <?php  
-  if (!$this->​helper('​customer'​)->​isLoggedIn()) { +      if (!$this->​helper('​customer'​)->​isLoggedIn()) { 
-  echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​header_sticky_block'​)->​toHtml();​  +      echo $this->​getLayout()->​createBlock('​cms/​block'​)->​setBlockId('​header_sticky_block'​)->​toHtml();​  
-  } ?> +      } ?> 
-  </​div>​+    </​div>​
   </​div>​   </​div>​
   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​   <div class="​col-lg-6 col-md-6 col-sm-12 col-xs-12">​
-  ​<div class="​top-links">​ +    ​<div class="​top-links">​ 
-  <ul class="​top-links-list">​ +      <ul class="​top-links-list">​ 
-  <?php if ($this->​helper('​customer'​)->​isLoggedIn()):​ ?> +        <?php if ($this->​helper('​customer'​)->​isLoggedIn()):​ ?> 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​logout'​);​ ?>"><​i class="​account-icon"></​i>​Logout</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​logout'​);​ ?>"><​i class="​account-icon"></​i>​Logout</​a></​li>​ 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account'​);​ ?>"><​i class="​signup-icon"></​i>​My Account</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account'​);​ ?>"><​i class="​signup-icon"></​i>​My Account</​a></​li>​ 
-  <?php else: ?> +        <?php else: ?> 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​login'​);​ ?>"><​i class="​account-icon"></​i>​Login</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​login'​);​ ?>"><​i class="​account-icon"></​i>​Login</​a></​li>​ 
-  <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​create'​);​ ?>"><​i class="​signup-icon"></​i>​Sign up</​a></​li>​ +        <​li><​a href="<?​php echo $this->​getUrl('​customer/​account/​create'​);​ ?>"><​i class="​signup-icon"></​i>​Sign up</​a></​li>​ 
-  <?php endif ?> +        <?php endif ?> 
-  <​li><​a href="<?​php echo Mage::​helper('​checkout/​url'​)->​getCheckoutUrl();​ ?>"><​i class="​checkout-icon"></​i>​Checkout</​a></​li>​ +        <​li><​a href="<?​php echo Mage::​helper('​checkout/​url'​)->​getCheckoutUrl();​ ?>"><​i class="​checkout-icon"></​i>​Checkout</​a></​li>​ 
-  <li class="​bulk-link">​ +        <li class="​bulk-link">​ 
-  <a href="<?​php echo $this->​getUrl('​quickshopping'​);​ ?>"><​i class="​bulkpro-icon"></​i>​Quick Shop</​a>​ +          <a href="<?​php echo $this->​getUrl('​quickshopping'​);​ ?>"><​i class="​bulkpro-icon"></​i>​Quick Shop</​a>​ 
-  </​li>​ +        </​li>​ 
-  <li class="​search-cart-cart-btn">​ +        <li class="​search-cart-cart-btn">​ 
-  <?php $_cartQty = Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty()?​Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty():'​0';​ ?> +          <?php $_cartQty = Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty()?​Mage::​getSingleton('​checkout/​cart'​)->​getSummaryQty():'​0';​ ?> 
-  <div id="​cart-main"​ class="​search-cart cart-btn <?php if($_cartQty != 0) echo '​color-red';​ ?>">​ +          <div id="​cart-main"​ class="​search-cart cart-btn <?php if($_cartQty != 0) echo '​color-red';​ ?>">​ 
-  <div class="​div_link-cart">​ +            <div class="​div_link-cart">​ 
-  <div class="​div_link-cart_inner"><?​php echo $this->​__('<​a href="​%s"​ id="​topcartlink"​ class="​top-cart"><​i class="​cart-icon"></​i><​span class="​item-cart">​ %s </​span>​items </​a>',​ $this->​getUrl('​checkout/​cart'​),​$_cartQty) ?> +              <div class="​div_link-cart_inner"><?​php echo $this->​__('<​a href="​%s"​ id="​topcartlink"​ class="​top-cart"><​i class="​cart-icon"></​i><​span class="​item-cart">​ %s </​span>​items </​a>',​ $this->​getUrl('​checkout/​cart'​),​$_cartQty) ?> 
-  <div id="​top_cart_sidebar"​ style="​display:​ none"><?​php echo $this->​getChildHtml('​em0050_cart_sidebar_top'​);?>​ +                <div id="​top_cart_sidebar"​ style="​display:​ none"><?​php echo $this->​getChildHtml('​em0050_cart_sidebar_top'​);?>​ 
-  </​div>​ +                </​div>​ 
-  </​div>​ +              </​div>​ 
-  </​div>​ +            </​div>​ 
-  </​div>​ +          </​div>​ 
-  </​li>​ +        </​li>​ 
-  </​ul>​ +      </​ul>​ 
-  </​div>​ +    </​div>​
-  ​</​div>​+
   </​div>​   </​div>​
 +</​div>​
 +</​code>​
 +
 +Now update the releated part of header.phtml:​
 +
 +<​code>​
 +32 <div class="​top-bar">​
 +33   <​div class="​container">​
 +34     <?​php echo $this->​getChildHtml('​toprow'​);​ ?>
 +35   </​div>​
 +36 </​div>​
 +</​code>​
  
-Now the header.phtml related part becomes +In the layout file, add the new block inside ​the header ​section:
-  32 <div class="​top-bar">​ +
-  33 <div class="​container">​ +
-  34 <?php echo $this->​getChildHtml('​toprow'​);​ ?> +
-  35 </​div>​ +
-  36 </​div>​+
  
-In layout file, add the new block insider header section: +<​code>​
- +
 [/​home/​user1/​public_html/​app/​design/​frontend/​default/​theme_revamp/​layout]#​ vi page.xml [/​home/​user1/​public_html/​app/​design/​frontend/​default/​theme_revamp/​layout]#​ vi page.xml
  
-  ​<block type="​core/​template"​ name="​toprow"​ as="​toprow"​ template="​page/​html/​toprow.phtml"​ />+<block type="​core/​template"​ name="​toprow"​ as="​toprow"​ template="​page/​html/​toprow.phtml"​ /
 +</code>
   ​   ​
-Last, in the LiteMage configuration,​ change the following:+Finally, in the LiteMage configuration,​ change the following:
  
-  * in the configuration,​ add “toprow” in Customized Block Names for “toplinks” Tag+  * In the configuration,​ add “toprow” in Customized Block Names for “toplinks” Tag
   * Flush Product and Categories When Product Qty Changes => "Flush product and categories only when stock status change"​   * Flush Product and Categories When Product Qty Changes => "Flush product and categories only when stock status change"​
   * Separate cache copy per customer group => Yes   * Separate cache copy per customer group => Yes
   * Track recently Viewed => No   * Track recently Viewed => No
-  *  
-Then flush LiteMage cache and Magento cache. 
  
-If you want to warm up for logged in users, you can put a list of user IDs from different user group under "Crawl on behalf of logged-in users".+Flush both LiteMage and Magento caches.
  • Admin
  • Last modified: 2017/05/03 20:01
  • by Michael Alegre