• Resolved holgee

    (@holgee)


    Hi,

    on our homepage, we´ve got a Onlineshop Widget in the header, which counts the number of products in the basket. This widget comes out of a function, which is located in seperate .php file and included via the wp functions.php.

    <div class="header-cart"> 
    <?php wpsg_cart_link(); ?>
    <?php wpsg_cart_dropdown(); ?> 
    </div><!-- End .header-cart -->

    The LS Cache is working perfect on the page, except that we had to exclude all pages to get the widget show the correct number of products. So i´m thinking of the ESI function of LightSpeed Cache, to exclude only the widget (or even more the corresponding code) …

    I´ve already enabled ESI it and try to integrate <esi:inline>, but nothing worked properly, or the widget isn´t shown.

    `<esi:inline name=”/basket” >
    <div class=”header-cart”>
    </esi:inline>
    <?php wpsg_cart_link(); ?>

    Is that the correct usage or i´m on the wrong way regarding the useage of ESI? I´m not so familar with the technical integration …

    Would be very happy, if someone had a suggestion or idea …

    Many thanks in advance
    <?php wpsg_cart_dropdown(); ?>
    </div><!– End .header-cart –>

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Hai Zheng⚡

    (@hailite)

    If that widget can use a shortcode to load the content, things will be easier. You can just change that [xxx] to [esi xxx], then the magic comes.

    If not, you need to use our api to make it work.

    Ref:
    https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api

    In the bottom there is a ESI Sample Code you can try the same way to code.

    Directly using <esi is not recommended in your case.

    Thread Starter holgee

    (@holgee)

    Hi,

    BIG thanks for the detailed explanation !!! Unfortunately, the widget can´t use a shortcode, unless i would make a widget out of the function (which as well would be possible).

    But i´ll have a look into this API thing and the sample code first …

    Once again: many thanks for your help!!!!

    Plugin Support Hai Zheng⚡

    (@hailite)

    You are most welcome.

    Thread Starter holgee

    (@holgee)

    Hi,

    only a short feedback regarding your suggestions:

    After some try & errors with the ESI API, i´ve made a plugin (or widget) out of the mentioned function. By calling this via <?php echo do_shortcode( '[esi basket-count ttl="0"]' ); ?> everything worked like it should! It´s possible to cache the whole page, except the count of the products in the shop basket in the header.

    Therefore: many thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘ESI // WordPress Function’ is closed to new replies.