Hi,
I have tried every way possible to get this done but I just cannot get the answer to it anywhere.
There seems to be an ongoing issue with Woocommerce and page caching. Basically, there are two main issues – pages like cart/checkout etc being cached and the cart widget in header.php being cached. This is not a fault of Woocommerce, themes or anything else. It’s just a fact of life. The caching of certain pages can be turned off on request by the likes of W3TC, but the cart widget being cached seems to remain an ongoing issue.
For reference, here is the PHP cart widget code from the header.php file…
<a class="mobile-link" href="<?php echo $woocommerce->cart->get_cart_url(); ?>"></a>
<div id="top-cart" class="shopping-cart-wrapper widget_shopping_cart">
<?php $cart_widget = new Etheme_WooCommerce_Widget_Cart(); $cart_widget->widget(); ?>
</div>
There are noted ways around it, such as late_init etc but all these KILL page caching benefits as it takes so much longer to load the page.
So, I am thinking that the best way around this would be to use AJAX onLoad() to update the cart accordingly, allowing (I assume) the page to load from the static page cache.
Can the 8Theme developers point my in the right direction in terms of how I get this done? I’ve looked through the add-to-cart.js to see how the widget it updated but I can’t see exactly how I can do this. Any advice on how I can do this? Providing I can get the required HTML from the code above via AJAX, writing it to the DOM shoudn’t be an issue.
BTW can the developers tell me where the Etheme_WooCommerce_Widget_Cart() class resides in the file structure? I would assume I can simply create a new PHP file with that class include in it, create a new instance of the class, invoke Etheme_WooCommerce_Widget_Cart::widget to get the HTML, and then use this as the response to the AJAX call to rewrite the code in the #top-cart div.
Any help GREATLY appreciated. I love the Blanco template and the site I have been working on is only being held back now by inability to cache pages without losing the cart widget functionality!
Please help! :o|
Thanks,
JN