• Resolved diegpl

    (@diegpl)


    Hi, at https://adegacaisdoporto.com.br/ for example, if I add a product in a product page and come back to home (after it being cached) the cart does not show the proper products number, it seems it works just for the woocommerce pages. How can I fix that? I am using Flatsome theme. Tks! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @diegpl

    Thank you for reaching out. Yes, the reason for this is the cart on the homepage is not fired with the WC fragment and the cache is cached in the browser cache. The solution for this is to either disable the HTML&XML Cache-control and expires header in Performance>Browser Cache settings, and that is fine since the page is already cached with the Page Cache or to use Page Fragment Cache and wrap the cart code with <mfunc> excluding that part of the page from the cache.

    You can check more about page fragment cache in our FAQ page.

    Thanks!

    Thread Starter diegpl

    (@diegpl)

    I have done what you said and it worked, but the page is much slower now, although Page Cache is enabled. That was not the expected, right? How can I debug the reason that happened, please? ??

    Thread Starter diegpl

    (@diegpl)

    Flatsome cart is in template-parts/header/partials/element-cart.php file. Should I wrap all its code with

    <!-- mfunc mysecurestring -->

    Or I also can use

    <!-- mclude mysecurestring -->

    to include the file instead to use the mfunc? Is that how it works in order to get it done? Tks! ??

    Thread Starter diegpl

    (@diegpl)

    To get the template-parts cart files, Flatsome is using this code. How could I implement the mclude on it?

    function dndstudio_refresh_header_cart_partials( WP_Customize_Manager $wp_customize ) {
    
    	if ( ! isset( $wp_customize->selective_refresh ) ) {
    	      return;
    	}
    
    	// Cart
    	$wp_customize->selective_refresh->add_partial( 'header-cart', array(
    	    'selector' => '.cart-item',
    	    'container_inclusive' => true,
    	    'settings' => array('cart_icon','header_cart_style','cart_icon_style','custom_cart_icon','header_cart_total','header_cart_title','html_cart_header'),
    	    'render_callback' => function() {
    	        get_template_part('template-parts/header/partials/element','cart');
    	    },
    	) );
    
    	// Cart
    	$wp_customize->selective_refresh->add_partial( 'header-cart', array(
    	    'selector' => '.header-nav .cart-item',
    	    'container_inclusive' => true,
    	    'settings' => array('cart_icon','header_cart_style','cart_icon_style','custom_cart_icon','header_cart_total','header_cart_title','html_cart_header'),
    	    'render_callback' => function() {
    	        get_template_part('template-parts/header/partials/element','cart');
    	    },
    	) );
    
    	$wp_customize->selective_refresh->add_partial( 'header-cart-mobile', array(
    	    'selector' => '.mobile-nav .cart-item',
    	    'container_inclusive' => true,
    	    'settings' => array('cart_icon','header_cart_style','cart_icon_style','custom_cart_icon','header_cart_total','header_cart_title','html_cart_header'),
    	    'render_callback' => function() {
    	        get_template_part('template-parts/header/partials/element','cart-mobile');
    	    },
    	) );
    
    }
    add_action( 'customize_register', 'dndstudio_refresh_header_cart_partials' );
    Thread Starter diegpl

    (@diegpl)

    This code run, but did not solve the issue:

    function dndstudio_refresh_header_cart_partials( WP_Customize_Manager $wp_customize ) {
    
    	if ( ! isset( $wp_customize->selective_refresh ) ) {
    	      return;
    	}
    
    	// Cart
    	$wp_customize->selective_refresh->add_partial( 'header-cart', array(
    	    'selector' => '.cart-item',
    	    'container_inclusive' => true,
    	    'settings' => array('cart_icon','header_cart_style','cart_icon_style','custom_cart_icon','header_cart_total','header_cart_title','html_cart_header'),
    	    'render_callback' => function() {
    	        mclude('template-parts/header/partials/element-cart.php');
    	    },
    	) );
    
    	// Cart
    	$wp_customize->selective_refresh->add_partial( 'header-cart', array(
    	    'selector' => '.header-nav .cart-item',
    	    'container_inclusive' => true,
    	    'settings' => array('cart_icon','header_cart_style','cart_icon_style','custom_cart_icon','header_cart_total','header_cart_title','html_cart_header'),
    	    'render_callback' => function() {
    	        mclude('template-parts/header/partials/element-cart.php');
    	    },
    	) );
    
    	$wp_customize->selective_refresh->add_partial( 'header-cart-mobile', array(
    	    'selector' => '.mobile-nav .cart-item',
    	    'container_inclusive' => true,
    	    'settings' => array('cart_icon','header_cart_style','cart_icon_style','custom_cart_icon','header_cart_total','header_cart_title','html_cart_header'),
    	    'render_callback' => function() {
    	        mclude('template-parts/header/partials/element-cart-mobile.php');
    	    },
    	) );
    
    }
    add_action( 'customize_register', 'dndstudio_refresh_header_cart_partials' );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Header cart not updating at home if Browser Cache is enabled’ is closed to new replies.