If you’re here it’s because your WooCommerce website is slow and you’re wondering why the “/?wc-ajax=get_refreshed_fragments” URL generates delays and server loads (spikes).
Besides, there is too much online literature about WooCommerce Ajax Cart Fragments (including specific plugins and performance plugin options), and you want to learn quickly what they are before understanding if and how you should disable them.
Performance optimization tools like Pingdom and GTMetrix often put the blame on this little WooCommerce functionality. And disabling it carefully can give you a boost in speed, page load and ultimately sales conversion rate.
This becomes a little complex – while adding an item to cart requires just its product ID, removing it from the cart forces you to know the “cart item key”. Japanese, I know, but just copy the snippet and you’re done!
Here’s a quick snippet you can simply copy/paste to show a “+” and a “-” on each side of the quantity number input on the WooCommerce single product page.
This snippet comes with a jQuery script as well, as we need to detect whether the plus or minus are clicked and consequently update the quantity input. jQuery might look difficult to many, but the beauty of this is that you don’t need to have a degree in jQuery – just copy/paste and see the magic happen.
Note: you will probably also require some additional CSS, as your theme might give a “float” to the quantity DIV while by default HTML buttons take inline-block. I’ve added some CSS valid for the Storefront theme below.
As a result, I definitely didn’t need the whole “Mini-Cart Widget Dropdown Content” either. To test, try to “hover” onto the shopping cart icon on the top right, and you’ll notice there is no cart dropdown 🙂
If you wish to test, go to my free video tutorial page called “How to Customize the WooCommerce Single Product Page“. As soon as the page loads a product is magically added to cart, so that the WooCommerce Checkout on that same page is populated with the hidden item. If you go to my Cart page right after visiting that landing page, you can verify there is a product in there.
One of the most common WooCommerce questions is: can I use WooCommerce to build a catalog of products (without add to cart, price… basically a product gallery)? Using WooCommerce for this case scenario is indeed very helpful – you can make the most of all the inbuilt features such as single product gallery and carousel, image zoom, product description tabs, attributes, categories, tags and related products. Basically a much better version than a standard image gallery.
Another question might be: can I disable the WooCommerce add to cart / cart / checkout functionality until the time I am able to sell my products? This is another common scenario that many WooCommerce store owners require.
Besides, certain products in your WooCommerce website might be for sale and others might not. In this case, you’d want to disable the add to cart functionality from specific categories or products.
Finally, you might want to restrict the cart / checkout functions to logged in, registered users only. This is if you run a wholesale business for example, and wish to hide your prices to the public.
Either way, when the “Add to Cart” button gets hidden, a contact form might be required – this is what I call a “Product Inquiry” form.
When talking about UX, or for very specific WooCommerce shops, you might need to “communicate” to the user a product is already in the Cart before re-adding it or increasing its quantity from the Shop/Category/Loop and Single Product pages.
The “Add to Cart” button label comes with a filter (actually 2 filters, one for the Single Product page and another for the other pages such as Shop), so all we need to do is targeting those two, “filter” the label text in case the product is already in the Cart, and return that back to WooCommerce. If this looks like Japanese to you don’t worry – simply copy/paste the snippet below! Continue reading WooCommerce: Rename “Add to Cart” Button if Product Already @ Cart
Here’s how to create custom WooCommerce Add to Cart links / buttons and make them add products to cart, redirect to specific pages. This tutorial includes also variable and grouped products, as well as quantities >1.
With this guide it’s much easier to place Add to Cart buttons on custom landing pages, pricing tables, blog posts and so on. Enjoy!
Quite an interesting functionality! A WooCommerce client wanted their Cart pre-filled with one product as soon as their customers accessed the website. I don’t remember the exact reason, but this could be useful when you want to give them a free product by default, or you want to send your visitors straight to checkout with a product already in the cart without letting them add anything first.
Adding an item to cart programmatically is the same as “automatically”. Basically, all users will have a default, non-empty Cart filled with an item of your choice. So, let’s see how this snippet works!
You may want to force users to login in order to see prices and add products to cart.
All you need is pasting the following code in your functions.php (please note: your theme may have overwritten some default WooCommerce functions, hence the code below may not work. Contact me if you need custom code). Enjoy!