• Resolved josnierop

    (@josnierop)


    Hey there,
    
    I asked my hosting provider to help but they sent me here, so I hope you can take a look!
    
    My website josnierop.nl is reasonably fast (not on mobile unfortunately, I’ll have to look into that).
    
    There’s one problem: the add to cart woocommerce button is very slow, on this page:?https://www.josnierop.nl/product/online-cursus/
    
    There are a few errors but I don’t know how to fix it. One customer already reported this problem ??
    
    My hosting provider gave the following information:
    
    – It’s an error in the file “wc-cart-functions.php”, line 185 
    – This line leads to a PHP warning:?if ( WC()->session->order_awaiting_payment > 0 ) {
    – This is a line from the error log:
    
    [Tue Mar 12 16:44:32.327927 2024] [lsapi:warn] [pid 455836:tid 139988528150272] [client 172.71.154.234:28122] [host?https://www.josnierop.nl]?Backend log: PHP Warning: Attempt to read property “order_awaiting_payment” on null in /home/u16265p11915/domains/josnierop.nl/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 185\n, referer:?https://www.josnierop.nl/ontwikkelomgeving/maatschappelijke-oorzaken-depressie-burn-out/
    
    “ontwikkelingomgeving” means “staging website”, which I deleted last week.
    
    – browser console errors:?https://media.zxcs.nl/i/8kNLL5YB
    
    You might be able to tell me how to fix this issue? Thank you so much!
    
    Kind regards,
    
    Jos
    
    P.S. I'm using Redis cache and Cloudflare but as far as I can tell all my optimisation plugins actually speed up my site, so there is a specific issue with the add to cart button. I already found a 'solution' on the internet to increase memory limit, but that didn't do anything.
    
    P.P.S. I'm not a developer/expert.

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hi @josnierop!

    Thank you for reaching out and giving a detailed explanation of the issue you have.

    I tested your site, and when I selected the Add to Cart button, I found that instead of displaying the addition to the cart, it takes you directly to the checkout page. There is no place to edit the order (Cart page). It looks like there is no cart page, or it is skipping it, and that might be causing the lag.

    As a next step to further check, kindly provide us with the following:

    • Your System Status: You can find it via WooCommerce > Status. Select ‘Get system report’ and then ‘Copy for support’. Once you do this, paste your response here.
    • ?Fatal Error Log: Share a copy of any fatal error log found under WooCommerce > Status > Logs (if available).

    Thanks.

    We are looking forward to your response!

    Thread Starter josnierop

    (@josnierop)

    Hi @judagutor!

    Thanks for your quick reply.

    You’re correct about the setup: I just sell one product, so after clicking on add to card I want customers to be directed to the checkout page directly. Click-and-pay.

    System status

    [ 40,531 bytes of unreadable mess removed ]

    Comments

    I deleted the WP-testing plugin because it provided some issues. After that no more fatal errors.

    Looking forward to your reply,

    Jos

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    That logs and system status often do not work here and make the reply an unreadable mess.

    Please do not post large code or responses like that here, it doesn’t work after ~10 lines or so.

    If you need share that data please use https://gist.github.com/ or https://pastebin.com/ or the like instead and post the link to that paste.

    Thread Starter josnierop

    (@josnierop)

    My bad @jdembowski, thanks for explaining.

    https://github.com/mathijsshareshiscode/josnierop
    Hope I did it correctly here.

    Hey, @josnierop!

    Thanks for sharing the reports.

    Do you mind sharing how you set up the Add to cart > Checkout jump?

    The lagging issue can be related to the theme. Can you please switch to a default theme such as Storefront and check if the issue persists?

    — Be sure you have a good backup in place of your full site and database. You can ask your host for backup functionality or you can consider using a service like Jetpack. If something goes wrong, you will be able to restore it.

    — It is important to consider as well a staging functionality in case you would not like to touch your production site (you can ask your host if they offer this service), or you can use WP Staging for quickly spinning up a new test site.

    Please let us know how it goes.

    Have a wonderful day!

    Thread Starter josnierop

    (@josnierop)

    Hey @carolm29,

    How I set it up:

    • I added this code to the child theme functions.php (before that I had a different solution, which was redirecting the shopping cart URL to the checkout URL with RankMath plugin; both of these options are slow).
    • Woocommerce plugin: in the products tab (settings), I unchecked the AJAX add to cart option.

    I created a staging website with the theme Storefront, the process is still too slow.

    Kind regards,

    J.

    PS. I use the theme GeneratePress, which is very fast.

    Thread Starter josnierop

    (@josnierop)

    Since I changed the way the redirect is set-up, I’ll provide the newest system report:

    https://github.com/mathijsshareshiscode/josnierop/blob/main/woocommerce-plugin/SystemStatusReport_www.josnierop.nl_2024-03-17T12-52-27.txt

    There were no new fatal errors.

    Link to the fatal errors march 9th and march 10th.

    Hi @josnierop!

    Thank you for providing further details on the issue.

    The reason why your site is lagging is that it is skipping the regular and recommended process WooCommerce uses when shopping on a site.

    There is no core feature in WooCommerce to redirect the Add to Cart button to the checkout page.

    I added this code to the child theme functions.php (before that I had a different solution, which was redirecting the shopping cart URL to the checkout URL with RankMath plugin; both of these options are slow).

    Since you are using plugins and custom code to change the core functionalities of WooCommerce, this topic is outside our scope of support. Kindly note that this forum is related to WooCommerce core features only.

    In this case, if you want to redirect your Add to Cart button directly to the checkout page, you could use an extension like Add to Cart RedirectCashier, or Quick Buy Now Button for WooCommerce.

    Although help with customization is outside our scope of support, you could try the following code snippet and see if this does the trick:

    php
    add_filter('woocommerce_add_to_cart_redirect', 'wc_skip_cart_redirect_to_checkout');
    
    function wc_skip_cart_redirect_to_checkout() {
        return wc_get_checkout_url();
    }

    You need to add this code to your child theme’s functions.php file or via a plugin that allows custom functions to be added easily, such as the Code Snippets plugin.

    Please don’t add custom code directly to your parent theme’s functions.php file because it will be wiped out when you update the theme.

    I hope this helps.

    Cheers!

    Thread Starter josnierop

    (@josnierop)

    Thanks for your reply.

    In the staging website, when clicking on the add to cart button, the shopping card page wasn’t skipped, but still the button was lagging, so there clearly is something wrong with the add to cart button. That is why I provided the error logs, I’m not able to make sense of it.

    Adding a little bit of custom code doesn’t make a button lag for 5 seconds right? I changed the code I used with your code and that also didn’t reduce the lag.

    Hi @josnierop!

    Thank you for reaching out back.

    Adding a little bit of custom code doesn’t make a button lag for 5 seconds right?

    It depends on the code, but let’s check this further and find the culprit of the issue.

    In the staging website, when clicking on the add to cart button, the shopping card page wasn’t skipped, but still the button was lagging, so there clearly is something wrong with the add to cart button. That is why I provided the error logs, I’m not able to make sense of it.

    I understand there is still a lag after the test you performed. Let’s try the following test on your staging site (if you haven’t done it yet):

    • Change your theme back to a default one like Storefront, or TwentyTwentyFour, (please do not use GeneratePress for the test)
    • Deactivate all plugins except WooCommerce
    • Deactivate all custom code you have related to the add to cart button.
    • Check again if the issue persists.

    Once you do the test, it should look something like this:

    Image link: https://i.ibb.co/BZJchcM/jnasjn.gif

    The results of this test will help us narrow the issue down and continue troubleshooting.

    You can have more information on how to perform a conflict test here: https://woo.com/document/how-to-test-for-conflicts/

    Thanks.

    Let us know how it goes for you.

    Thread Starter josnierop

    (@josnierop)

    Thanks for your reply!

    Let’s see:

    1. Initial test in staging: lagging button.
    2. Switch to TwentyTwentyFour theme: the lower blue button is slow and the upper add to cart button is a bit faster (the lower button skips the shopping cart and the upper button just shows a banner ‘added to shopping cart’.
    3. Disable all plugins except Woo: both buttons are fast. ‘Checkout Field Editor for WooCommerce‘ plugin slows down the lower button upon activation of the plugin by lets say .5 secs.

    Unfortunately I’ll have to finish this later I don’t have enough time right now!

    Hi @josnierop!

    Thank you for the update on the test you are performing.

    Disable all plugins except Woo: both buttons are fast.

    That’s great; the core add-to-cart function runs as it should. Now, you can continue testing until you find the one(s) creating the lag.

    Checkout Field Editor for WooCommerce‘ plugin slows down the lower button upon activation of the plugin by lets say .5 secs.

    It is good to know that one plugin is slowing things down; kindly note that it could be a combination of plugins causing it, so it is a good thing to perform the test completely.

    Unfortunately I’ll have to finish this later I don’t have enough time right now!

    No worries! Please keep us posted and let us know how it goes for you.

    Cheers!

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Add to cart button lagging (5 sec)’ is closed to new replies.