WordPress + WooCommerce - disabling cart AJAX (fragments) in 3.4.0? - php

WooCommerce has a script that runs on every page, upon every page reload, that adds 1-3 seconds to loading time. It's the "wc-ajax get_refreshed_fragments" function.
All this does is check whether the shopping cart totals have changed. Which is nice to have on the product page - but completely unnecessary on the home page or category page or any of the text-content pages.
There are manual methods (dequeue script commands to be added to functions.php) and plugins (PerfMatters, LittleBizzy's Disable Cart Fragments, etc) to remove this, which worked... right up until the latest WooCommerce update.
Is there a solution for disabling this script, in the latest version of WooCommerce?

Unfortunately your information is wrong:
PerfMatters (Brian Jackson) took their code from our GPL plugin without credit, which was originally shared by Jeff Matson on his blog back in 2016 (credited in our readme).
wp_dequeue_script('wc-cart-fragments');
Disable Cart Fragments still works fine in WC 3.4+
If it's not working on your site, most likely your theme is to blame... confirm by activating a different theme and disabling all other plugins that may be enqueuing the cart, etc.
Update: since so many people are now referring to this thread, I'd like to once again confirm that Kinsta (web host) is now promoting the stolen code from LittleBizzy plugins, and have contacted me to state they have nothing to do with PerfMatters. When I asked them when they'd be removing all the links and promotional material on their website for PerfMatters, they went silent...
P.S. Thanks to WP Engine and WP Rocket for crediting us! :)

Related

How to resolve duplicate stock movement and order notifications in Woocommerce

I have been troubleshooting this issue for the last few weeks and have not been able to resolve.
We are experiencing the following (intermittently) when an order is placed by a customer.
Stock movement is duplicated
Order notes are duplicated
Email notifications are duplicated (to all parties)
Backorders are created (if the stock on hand is not sufficient to handle the duplicate qty). Example: initial inventory = 1 unit. 1 unit is purchased but the stock movement is duplicated which takes inventory to -1 causing a backorder, despite back orders being set to "do not allow".
Stack
Osmosis theme (+ child theme) - v4.3.6 (just updated to latest version)
Woocommerce v6.4.1
WordPress v5.9.3
PHP v7.4.28
Flywheel/5.1.0, nginx
The issue appears to have started a couple of weeks prior to a migration to a new host. A review of orders prior to the migration showed that order notes were already duplicating. After the move to the new host, it seems the stock movement started to duplicate (as well as order notification emails).
I reached out to Flywheel, they took a look but could not see anything suspicious-looking in the logs other than some fatal errors in the theme. I updated the theme. This resolved the fatal errors but not the order issue. Flywheel also adjusted the PHP memory, but no dice on the order issues. They have not provided much more help.
I updated a bunch of plugins at the same time as I migrated the site to Flywheel, so a possible conflict with a plugin may exist.
I tested in a staging environment with themes and plugins disabled but can not replicate.
It's hard to tell which plugin/theme might be causing a conflict on the staging site, as the issue is intermittent, so it's hard to narrow down which plugin, or if it is even a conflict. We also don't have the volume of orders going through the staging site, so hard to figure out. We would need to process several test orders over the course of a day. Which I guess we can do.
I did some googling and saw a bunch of posts on a similar issue relating to the payment gateway, and a possible conflict between using the hosted payment page or merchant payment page. I reached out to the developer (Windcave / Payment Express). They were not aware of any conflicts but sent me an older version of the plugin so I could roll it back. No dice. I also had the client reach out to Windcave directly to check their account was configured correctly and all appears to be as it should.
I've checked all Woocommerce settings, run all updates on plugins, reviewed the woocommerce status report, and checked logs.
I'm left with placing a bunch of test orders in the staging site over a few days until I can narrow down a possible plugin conflict, but wanted to fire this query through here first to see if anyone had come across something simiar and can help me resolve.
Would greatly appreciate some help.
Thanks
Josh
I think it can relate some of the WordPress hooks that are used for checkout page. You can check in this link "https://www.businessbloomer.com/woocommerce-visual-hook-guide-checkout-page/" for the hooks that can possible used on checkout page (or) before order create hooks. Try to compare these hooks names and if you used these hooks in child theme > functions.php or plugins. Some of hooks can trigger 2 or 3 times so it can possible be the problem.

Strange WooCommerce database related issue

I have a strange WooCommerce issue on one of my sites. It's a popular webshop with thousands of products. Most likely the issue is there for a long time but we just noticed it.
The problem: A lot of products are not showing up on the frontend. All of those are visible in the backend, all of them are live, all of those are in stock. So they should show up. Some of the store products are visible, some of them are not. There's no logic in this. BUT... if I just edit a missing product and just simply re-save it in the backend it shows up in the frontend right away.
Most likely the issue is related to the 2.x to 3.x database upgrade: "3.0.0 instroduces a new product visibility taxonomy; catalog, search, hidden, featured, outofstock are terms. These are set on upgrade and help filter products in the catalog during frontend queries."
My theory is that this database upgrade didn't finish at that time for some reason.
So the solution would be to run it again or to find an automatic way to emulate the "save" feature that I do manually if I edit and save a missing product in the backend. But the manual way is simply not an option when I have thousands of products.
I just want all available products to appear in the frontend too. Do you have any idea how can I solve this?
P.s: I have already tried switching back to a default theme and disabling every other plugin except WooCommerce. It's clearly a database related WooCommerce issue. And yes, I have the latest WP and the latest 3.x Woo. The PHP version is 7.2.
Thank you in advance!

Woocommerce 3.8 changed price not showing change in frontend

I have a price update on all products to sync the shop prices with a web service XML. This is the part that updates the price. It's run with a server cronjob every hour. The problem is that, although I can see the prices updated, in wp-admin edit product pages, in the admin product list, and in the front end it still shows the old prices.
$product = new WC_Product( $pid );
update_post_meta($pid, '_regular_price', $set_price);
update_post_meta($pid, '_price', $set_price);
$product->set_regular_price($set_price);
$product->set_price($set_price);
$product->save();
What am I doing wrong here?
Just an update something i just notice, for example on products that have the the sale_price set, on the admin edit page its all ok but on admin list product page and frontend the sale price shows the regular_price.
After more digging it seems that the issue maybe related to the save instruction. All the fields are populated correctly with the changes, so if i go to edit product page and add a change, i.e. add a 0 in regular price and then save it assumes the changes made.
Is there a way that i can see the query executed by wordpress/woocomerce when pressing the save button on a edit product page?
Yes, it is a cache problem for WooCommerce when you programmatically changed the product prices.
Not sure you have solved it or not, I have the same issue as your one, I update the price programmatically with WC hooks but the price was not updated in the related products slider.
I solve the issue by adding following code to my theme:
// Handling price caching
add_filter( 'woocommerce_get_variation_prices_hash', 'add_price_multiplier_to_variation_prices_hash', 99, 3 );
function add_price_multiplier_to_variation_prices_hash( $price_hash, $product, $for_display ) {
$price_hash[] = get_price_multiplier();
return $price_hash;
}
all credits belong to this post, you can get more information on why use that.
Hope it helps anyone who runs into the same issue. Have a good day!
Yeah, sounds like a Cache problem…
Clear Cache in Your WordPress Caching Plugin
If you are using a WordPress caching plugin on your site, then you need to clear your plugin cache. Most caching plugins allow you to easily do that from the plugin’s Settings page.
Clear Cache in WP Rocket
WP Rocket is the best WordPress caching plugin on the market. The best part about using WP Rocket is that it proactively builds your WordPress cache in the background, so your users are always served a cached version.
It also makes it very easy to clear caches files with a single click.
Simply go to the Settings » WP Rocket page and click on the ‘Clear Cache’ button under the dashboard tab.
WP Rocket will now clear all cached files for you.

Word press Cart update issue

I have developed a wordpress website on my local server which works perfectly. The shopping experience of adding items to the basket and checkout works as expected but when I transferred it to the live server, this stops working correctly (the Mini Cart doesn’t update, and items get deleted automatically).
Despite previous suspicions, there is no custom code involved – the only variable is the live server.
I wonder if you please advise on what might possibly be going on, and if you’ve seen something similar before – perhaps cache/refresh/something else??
The website is approaching the launch date, and this is the final mystery.
Steps to find the issue:
Basket(cart) with zero item should display mini cart with empty basket message
Add two or more item to the baske, you have to refresh the page to get updated and once you navigate away from that page, the icon stop working.
I have cleared the cahce, and searched all over internet but no solution.
Site: http://www.test2.hydro-x.co.uk/

prestashop cart block disappeared

I found a problem in my webpage after days since last modified. The block cart disappeared from page. It is available, it is linked to the top, it worked well but now I don't know if maybe other person has modified it or what because it disappeared from day to night.
The web is venuspleasure.com and the cart WAS right in the menu bar. It also disappeared the add to cart button. I looked from solutions online and I tried to put available the user block and the cart (they already were but I refresh them) I now php so you can explain me if you see something in my code. Maybe I delete something, dunno :(

Categories