Increase WooCommerce page speed – wc-ajax=get_refreshed_fragments

The “wc-ajax=get_refreshed_fragments” is used by WooCommerce to update the cart when users go to a cached page. Since WooCommerce is a resource intensive plugin which may use lots of server resources to load all relevant styles and scripts, it make sense to dequeue all WooCommerce related stuff on the blog posts or home page. Basically, you will allow WooCommerce scripts to run on shop relevant pages, allowing all other pages to load faster.

Solution provided  by alenabdula on gist.github.com. Add the following code to your functions.php file

Other things you can try to increase speed

Stop Heartbeat API

Add this code to functions.php file of your theme.

Note: stopping the heartbeat API will disable the auto save and revisions (you will have to manually Save Draft to save your content). Also, you will not see any real-time stats if any of your installed plugin uses the heartbeat API to update their content from the server.

Increase WP Memory

You should also increase WP memory to 256 MB. Add the following code to your wp-config.php file:

 

Automatically Complete all Orders

By default, WooCommerce orders are saved as Processing. Only orders that contain “downloadable” products are automatically completed upon payment. In case you sell virtual products you may want to automatically complete all orders as they arrive, saving you a lot of time by not manually approve/complete orders.

There are some plugins available you can use to let WooCommerce process orders automatically if the they payment is complete. However, there is an easier way to do this by using a snippet. Just add the following code to the end of your functions.php file which is located in “wp-content/themes/your-theme-name/”, or  “wp-content/themes/your-child-theme-name/” if you are using a child theme:

The above method works only for online payments (PayPal and Credit cards gateway payments). If you are using BACS (direct bank transfer), Cheque or COD (cash on delivery) payment methods  you would need to implement a conditional code based on selected payment method – i.e. if the selected payment method IS NOT BACS, COD or Cheque then apply the above snippet to automatically complete order.

Using the above updated snippet the BACS, COD and Cheque payment methods will be ignored and keep their original status, and will automatically complete orders for paid orders only.

Hide coupon on cart page only

To hide coupon on cart page for WooCommerce add the following code in the functions.php file:

Additionally, if you want to remove the coupon on the checkout page, add the following code in the functions.php file:

 

Leave a Reply

Your email address will not be published. Required fields are marked *