Disable Cart Fragments

Description

Completely disables the AJAX cart fragments feature in WooCommerce for a huge boost in loading speed (redirect to cart page highly recommended).

Our related OSS projects:

The Long Version

Disable Cart Fragments is a simple plugin that disables the AJAX ‘cart fragments’ feature in WooCommerce. That feature automatically updates the cart total in your shopping cart without having to refresh the page. The problem with this is that is severely slows down many WooCommerce websites especially on shared hosting servers. Plus, the feature isn’t even used in many cases. We recommend that if you install this plugin, you either disable it selectively on certain pages (see the Installation tab) or if installing as one-click then make sure you enable ‘redirect to cart page’ option in WooCommerce settings so that when a customer adds a product to their Cart, it redirects to the Cart page automatically so as to not confuse them about what happened to their chosen product.

This plugin removes e.g.

/* <![CDATA[ */
var wc_cart_fragments_params = {"ajax_url":"\/wp-admin\/admin-ajax.php","wc_ajax_url":"\/about?wc-ajax=%%endpoint%%","fragment_name":"wc_fragments"};
/* ]]> */
</script>
<script type='text/javascript' src='//example.com/wp-content/plugins/woocommerce/assets/js/frontend/cart-fragments.min.js'></script>

You can selectively disable using a defined constant:

define('DISABLE_CART_FRAGMENTS', '123,456,789');

For initial release we’ve implemented via dequeue rather than print scripts, will review based on feedback.

Compatibility

This plugin has been designed for use on LEMP (Nginx) web servers with PHP 7.0 and MySQL 5.7 to achieve best performance. All of our plugins are meant for single site WordPress installations only; for both performance and security reasons, we highly recommend against using WordPress Multisite for the vast majority of projects.

Defined Constants

The following defined constants are supported by this plugin:

  • define('DISABLE_NAG_NOTICES', true);
  • define('DISABLE_CART_FRAGMENTS', '123,456,789');

Plugin Features

  • Settings Page: No
  • Premium Version Available: Yes (Speed Demon)
  • Includes Media (Images, Icons, Etc): No
  • Includes CSS: No
  • Database Storage: Yes
    • Transients: No
    • Options: Yes
    • Creates New Tables: No
  • Database Queries: Backend Only (Options API)
  • Must-Use Support: Yes (Use With Autoloader)
  • Multisite Support: No
  • Uninstalls Data: Yes

WP Admin Notices

This plugin generates multiple Admin Notices in the WP Admin dashboard. The first is a notice that fires during plugin activation which recommends several related free plugins that we believe will enhance this plugin’s features; this notice will re-appear approximately once every 6 months as our code and recommendations evolve. The second is a notice that fires a few days after plugin activation which asks for a 5-star rating of this plugin on its WordPress.org profile page. This notice will re-appear approximately once every 9 months. These notices can be dismissed by clicking the (x) symbol in the upper right of the notice box. These notices may annoy or confuse certain users, but are appreciated by the majority of our userbase, who understand that these notices support our free contributions to the WordPress community while providing valuable (free) recommendations for optimizing their website.

If you feel that these notices are too annoying, than we encourage you to consider one or more of our upcoming premium plugins that combine several free plugin features into a single control panel, or even consider developing your own plugins for WordPress, if supporting free plugin authors is too frustrating for you. A final alternative would be to place the defined constant mentioned below inside of your wp-config.php file to manually hide this plugin’s nag notices:

define('DISABLE_NAG_NOTICES', true);

Note: This defined constant will only affect the notices mentioned above, and will not affect any other notices generated by this plugin or other plugins, such as one-time notices that communicate with admin-level users.

Inspiration

Free Plugins

Premium Plugins

Special Thanks

Disclaimer

We released this plugin in response to our managed hosting clients asking for better access to their server, and our primary goal will remain supporting that purpose. Although we are 100% open to fielding requests from the WordPress community, we kindly ask that you keep the above-mentioned goals in mind… thanks!

Installation

  1. Upload to /wp-content/plugins/disable-cart-fragments-littlebizzy
  2. Activate via WP Admin > Plugins
  3. Test the plugin by refreshing pages and checking source code after clearing caches
  4. To disable cart fragments on specific posts/pages (using their ID), refer to below defined constant:

    define(‘DISABLE_CART_FRAGMENTS’, ‘123,456,789’);

FAQ

Installation Instructions
  1. Upload to /wp-content/plugins/disable-cart-fragments-littlebizzy
  2. Activate via WP Admin > Plugins
  3. Test the plugin by refreshing pages and checking source code after clearing caches
  4. To disable cart fragments on specific posts/pages (using their ID), refer to below defined constant:

    define(‘DISABLE_CART_FRAGMENTS’, ‘123,456,789’);

Does this plugin disable my WooCommerce shopping cart?

Nope, it only disables AJAX features of add-to-cart. Refreshing the page will still show cart totals in worst case scenarios, but in most scenarios the add-to-cart functions are not apparently changed.

Are there other recommendations to keep in mind?

Yes, you should enable redirect to cart page in WooCommerce settings to ensure customers aren’t confused. This will make sure that after adding an item to their Cart, they are automatically redirected to the Cart page each time. You should also disable AJAX add to cart on archives page because this plugin disables that AJAX site-wide by default.

How can I change this plugin’s settings?

This plugin does not have a settings page and is designed for speed and simplicity.

I have a suggestion, how can I let you know?

Please avoid leaving negative reviews in order to get a feature implemented. Instead, we kindly ask that you post your feedback on the wordpress.org support forums by tagging this plugin in your post. If needed, you may also contact our homepage.

Reviews

Pretty good…

Works – but not with PHP 5.3. It is easy to make it work with this version, if you change the references to arrays in a few places.

Great Plugin to disable cart fragments

This plugin works as advertised, it is small, does not conflict with anything else and it is a must if you want to disable cart fragments without touching your files. Thank you for providing this!

Read all 21 reviews

Contributors & Developers

“Disable Cart Fragments” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.1.2

  • added WC support plugin headers (meta) to plugin root file

1.1.1

  • added WC support plugin headers (meta) to readme

1.1.0

  • tested with WooCommerce 3.4
  • tested with PHP 7.1
  • tested with PHP 7.2
  • tested with alleged conflicting plugins e.g. WooCommerce Cart, WooCommerce Better Usability
  • plugin re-written with PHP namespaces
  • object-oriented codebase
  • optimized plugin code (e.g. moved notices to new folder)

1.0.9

  • added warning for Multisite installations
  • updated recommended plugins

1.0.8

  • tested with WP 4.9
  • support for DISABLE_NAG_NOTICES

1.0.7

  • added WP.org rating request notice
  • updated recommended plugins
  • optimized plugin code

1.0.6

  • minor code tweaks
  • updated recommended plugins

1.0.5

  • updated recommended plugins

1.0.4

  • added recommended plugins notice

1.0.3

  • tested with WP 4.8

1.0.2

  • updated plugin meta

1.0.1

  • updated plugin meta

1.0.0

  • initial release