Page with comments not working and dynamic refresh of shopping cart

This topic has 13 replies, 4 voices, and was last updated 9 years, 2 months ago ago by wjnmudie

  • Avatar: keithop
    Keith
    Participant
    April 21, 2015 at 10:02

    Hi,

    Thanks for a great theme! Two questions please…

    1. I have a page (not a post) with allow comments enabled – but the comments reply box does not appear. Can this be fixed? (apparently needs comments_template(); adding to page.php or something like that – but I don’t want to modify core files to avoid breaking on theme update)?
    2. Is it possible to have an ajax update/refresh of the shopping cart contents (top right of screen) at the end of every page load?

    Reason being that if one leverages the performance enhancement of w3 total cache page caching (which makes a huge difference to response time), the shopping cart at the top right obviously will be cached as being empty even when there is something in the cart… When an item is added to or removed from the cart, ajax updates the cart at the top anyway to the correct status, but only until another cached page is loaded.

    By updating the shopping cart dynamically on page load, the user gets to see the correct contents throughout the site.

    If this is not possible yet could it please be added to the development pipeline or perhaps let me know the code to call and I can alter it myself? Using wp e-commerce.

    Many thanks,

    Keith

    12 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    April 21, 2015 at 14:58

    Hello,

    1. Please provide us with a page link where comments don’t appear and wp-admin panel credentials in Private Content.

    2. Unfortunately there is no such possibility. We’ll take your query into our account and try to implement it in future updates.

    Thank you.
    Regards,
    Eva Kemp.

    Avatar: keithop
    Keith
    Participant
    April 21, 2015 at 15:24

    Thanks for the quick response, URL of page where comments box does not appear is in the private details box below… unfortunately due to data protection laws I cannot currently give you access to the admin page of the website as personal customer identification data is available there. I am more than willing to report back and do anything you require remotely however.

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Support staff
    April 21, 2015 at 19:37

    Hello,

    Sorry for inconveniences.
    To add comments section for pages you need add this code in wp-content/themes/blanco/pages.php file (after line 29):

    <?php // If comments are open or we have at least one comment, load up the comment template.
    		if ( comments_open() || get_comments_number() ) :
    			comments_template();
    		endif;
    	?>

    Please try it.

    Thank you.
    Regards,
    Eva Kemp.

    Avatar: keithop
    Keith
    Participant
    April 21, 2015 at 21:46

    Thanks eva, I have added this to both page.php and onecolumn-page.php (as this is the majority of the site) and that seems to be all working now! Will this be rolled into any updates or will we have to edit this every time there is an update to the theme?

    Do you or anyone else there have any clues about the difficulty of having the shopping cart dynamically reload on page load ? I am happy to have a look if someone can point me in the right direction (the required jquery/php code to call etc)? This is quite important for us as the performance benefit of caching cannot easily be ignored.

    Thanks again

    Keith

    Avatar: Brian Johnson
    Brian Johnson
    Member
    April 22, 2015 at 12:57

    You are welcome!
    Please clarify your question with more details/screenshots and describe more widely what is desirable behavior of the cart.

    With best regards
    Brian Johnson

    Avatar: keithop
    Keith
    Participant
    April 26, 2015 at 15:38

    I found some code in wp e-commerce that does an ajax update of the shopping cart when used as a widget – there is a wpsc_cart_loading class or similar and it updates this on page load… I’ve changed the code to look at the cart-wrapper class instead and that seems to do the trick!

    btw there is another issue you have when used with the latest v3.9 of wp e-commerce – the ‘same as billing address’ button doesn’t work on checkout – the html in the theme wpsc-shopping-cart_page.php page needs updating to the following:

    from:
    <input type='checkbox' value='true' name='shippingSameBilling' id='shippingSameBilling' <?php echo $checked; ?> />

    to:
    <input type='checkbox' data-wpsc-meta-key="shippingSameBilling" value='true' class= "wpsc-visitor-meta" name='shippingSameBilling' id='shippingSameBilling' <?php echo $checked; ?> />

    Avatar: wjnmudie
    wjnmudie
    Participant
    April 30, 2015 at 12:02

    Keithop…

    I found some code in wp e-commerce that does an ajax update of the shopping cart when used as a widget – there is a wpsc_cart_loading class or similar and it updates this on page load… I’ve changed the code to look at the cart-wrapper class instead and that seems to do the trick!

    Can you PLEASE outline to me exactly how you did this? I have previous asked about this issue here…

    https://www.8theme.com/topic/dynamically-updating-the-cart-widget-via-ajax/

    But I was never able to solve it and, as a result, I had to take caching off which is badly affecting user experience and is having a knock-on effect on my SEO. If you could just give me a slightly more specific description of what you did, I should be able to modify this myself.

    PLEASE HELP! :o)

    Avatar: wjnmudie
    wjnmudie
    Participant
    May 2, 2015 at 16:21

    Just wanted to bump this again.

    8Theme staff – do you know what Keith is talking about? Could you possibly enlighten or perhaps email Keith just so he knows there is a response on this thread (as he may have missed it) please? I am DESPERATE to get this issue fixed.

    Avatar: keithop
    Keith
    Participant
    May 2, 2015 at 16:42

    wjnmudie

    It’s a bit of a hack, and will stop the widget from Ajax updating, but seems to work with the Blanco theme…

    Look around line 1258 in plugins/wp-e-commerce/core/js/wp-e-commerce.js

    change

            if ( jQuery( 'div.wpsc_cart_loading' ).length  ) {
                    if ( ! ( jQuery( 'table.wpsc_checkout_table' ).length && jQuery( '.wpsc_buy_button' ).length) ) {
                            jQuery( 'div.wpsc_cart_loading' ).ready( function(){
    

    to

            if ( jQuery( 'div.shopping-cart-wrapper' ).length  ) {
                    if ( ! ( jQuery( 'table.wpsc_checkout_table' ).length && jQuery( '.wpsc_buy_button' ).length) ) {
                            jQuery( 'div.shopping-cart-wrapper' ).ready( function(){
    

    I don’t use the cart widget so it doesn’t bother me… I guess could do both with a code duplication, one to target the wpsc_cart_loading class and the other for the shopping-cart-wrapper class as in blanco.

    K

    Avatar: wjnmudie
    wjnmudie
    Participant
    May 28, 2015 at 00:01

    Keith,

    Apologies for not getting back to you sooner regarding your input and thanks for your help. I have been very busy and have also been trying a different workaround for this that I thought might work but I am have come to a dead end.

    Regarding your solution above – are you using the WP E-Commerce plugin or just copying over the JS above?

    Also, how quickly is the widget updating on your site? Is it instant (or almost instant)? One of the problems with running AJAX in WP is that admin-ajax.php runs the entire application, which is very slow.

    Avatar: keithop
    Keith
    Participant
    August 4, 2015 at 20:20

    You are right, it takes about 500ms to update as it calls admin-ajax.php every time.. (although is this really that bad?)

    Did you find any other way around it? It would be much nicer if it were almost instant !

    I have looked at fragment caching with w3tc late initialisation but couldn’t get that to do anything sensible at all.

    Avatar: wjnmudie
    wjnmudie
    Participant
    August 15, 2015 at 20:11

    Sory for the delay in responding to you.

    I tried and tried and tried but it seems that there is always going to be a bottleneck on AJAX calls with WP because ajax-admin is so heavy – there doesn’t seem to be a way of effectively running an AJAX call in a console environment.

    I gave up with all attempts at fragment caching… there just doesn’t seem to be a way to do it.

    The solution? I am so sick of working with WordPress now that I am looking to move over to Shopify ASAP. I just can’t justify wasting any more of my time with WordPress. Blanco is not the issue – I like the template but, as a framework, WP is just awful beyond belief.

  • Viewing 13 results - 1 through 13 (of 13 total)

The issue related to '‘Page with comments not working and dynamic refresh of shopping cart’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.