Magento 2 Add to Cart is Slow? Fix it in 5 Simple Steps
When you’re starting a retail business, you’re likely to put in a lot of effort and spend a great deal of money into boosting sales. You can provide the most competitive rates, free shipping, and superior user experience, but if the checkout is too slow, you’re going to lose hard-earned customers.
Here are some facts:
- 46% of customers name checkout speed as a key aspect that defines whether or not they will return to a site or recommend the online store to their friends.
- Shopping cart abandonment causes retailers to lose $18 billion in sales revenue annually.
In this article, we’re going to explain how to speed up Add to Cart in Magento 2 to boost your sales.
Why do customers abandon their carts?
There are many reasons for shopping cart abandonment, but the most common include:
- High product price
- Payment security risks
- Unexpectedly high shipping costs
- The requirement to create an account before purchase
- Slow or difficult checkout procedure
This last point is the basis for today’s blog post. The slow checkout page loading makes customers doubt if their order even went through.
5 tips on how to tune up Magento 2 Add to Cart
Magento 2 Add to Cart can be slow due to the fact that with Magento 1 and 2, it’s impossible to use caching when the product is added to the cart, and in each particular case, you should expect a unique result. There are numerous factors that affect these results - from the number of products in stock to all kinds of general or personal discounts. All of these details make the process so complex and time-consuming.
However, even uncached content can be loaded really fast. To identify the reasons for slow checkout and discover the right solution to fix the most common issues, you’ll need to perform a code audit.
There are different reasons why something doesn’t work properly: template failures, unnecessary extension, server configuration issues, insufficient resource distribution, etc.
To obtain better results in boosting up checkout speed, you should consider a combination of multiple actions. There are various ways to speed up Magento Add to Cart. Follow these tips to guarantee return customers and increased sales.
- Turn off unused shopping cart price rules
Slow Magento shopping cart loading time can be caused by shopping cart price rules combined with the number of products in your cart. Magento calculates the shopping cart final price, using all of the enabled price rules before giving you the final figure.
Certainly, a busy online shop would have dozens of irrelevant cart rules which reduce Magento Add to Cart and Checkout speed. Try turning off all of your additional shopping cart price rules to verify if this is the source of your problem. Disabling all unused rules ensures considerable productivity increase to both the Cart and Checkout.
- Perform code refactoring of the extensions that reduce the speed of your Magento 2 Add to Cart
Extensions you purchase from unknown vendors or downloaded for free are often poorly coded by average developers with disregard for performance benchmarks. Sometimes there are just too many third-party extensions integrated into the ecommerce store.
Therefore, Add to Cart Magento extensions can seriously slow the store down. When you install extensions on your online store, it implies not only loading your website content but also your extensions related to Add to Cart functionality.
There are two ways of fixing this. The first is to review and perform code refactoring of all the Add to Cart Magento extensions on your website. If the problem is in the extension code, contact the vendor and complain about the performance problem. A trusted development agency can help you to optimize the extension that interferes with the Cart performance.
The second thing you can do is go through each extension and analyze whether or not you really need them. If you don’t need them, start disabling your least important extensions one by one and check if it changes the checkout speed. After benchmarking the speed, you will see that your website is running much faster. Search for other extensions that don’t have an impact on your Magento Add to Cart performance as much. Ultimately, this extension can’t be the only one available on the Magento Marketplace providing the same functionality.
- Analyze all Magento 2 Add to Cart events to get rid of the slow-down effect
One of the key aspects to get rid of the slow-down effect is to analyze thoroughly the amount of all Magento 2 Add to Cart events. Add to Cart events are sent by modules when particular actions are driven. When an event is sent, it can transmit data to any observers configured to watch that event. Observers are a certain kind of Magento classes that can have an impact on performance or business logic. Such observers can considerably slow down the shopping cart loading time for the customers.
The events can be specific or general. You need to start by analyzing events that are specific to the checkout. Check if observers for these events can be combined or place them into a separate script. This script should be launched after the process of adding the product has already been completed. Afterward, go back to general events. Your store’s codebase may contain a piece of code that are always executed, regardless of what action is taking place at the moment. In this case, we recommend looking through these fragments and check whether it is possible to avoid executing this code every time a customer adds the product to a shopping cart.
Some of the slowdowns can be tracked using Blackfire (a performance monitoring tool that uses PHP applications to collect data about consumed server resources). We recommend modifying these requests and minimize irrelevant events to tune up the Magento 2 Add to Cart.
- Optimize the design to avoid unnecessary elements
One more way to speed up Magento 2 Add to Cart is to optimize the design to avoid unnecessary elements. Estimated Shipping and Cross-sell are placed right in the shopping cart before the checkout process. Estimated Shipping is a good tool that helps to calculate the shipping rate per delivery method and location. Cross-sell products are applied to lead the customers to other categories at your ecommerce store.
Nevertheless, if the Magento 2 Add to Cart is too slow, you can place this information on the checkout page. This will help if your Cart is overburdened with functionality and you can’t balance it right.
If you need to show estimated shipping and cross-sell elements, then you can do this asynchronously. In this case, the bulk of the page will be loaded immediately, but it will contain the placeholders. After the main content is completely loaded, additional sections can be loaded asynchronously.
If there is no necessity to demonstrate the Tax and Shipping Estimate and Cross-sells functionality in the shopping cart, you can remove them. Removing the Estimate Shipping box is a simple procedure.
In your checkout_cart_index.xml add the following to remove the block:
<checkout_cart_index> <remove name="checkout.cart.shipping" /> </checkout_cart_index>
You can use this section using this tag:
<referenceBlock name="checkout.cart.shipping" remove="true" /> <!-- use this code -->
To remove cross-sells from Magento 2 Add to Cart:
<?xml version="1.0"?> <page layout="1column" >="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="checkout.cart.crosssell" remove="true"/> </body> </page>
- Check the overall website performance to locate bottlenecks and optimize the codebase
In order to find the bottleneck, we recommend performing a technical audit of various parts of the ecommerce store (frontend and backend). Poorly written code makes ecommerce websites slow and difficult to maintain. The aim of code optimization is to discover mistakes overlooked in the previous development phase and improve the overall quality of the custom code.
Once you find the bottlenecks in the Add to Cart code, fix them and test the functionality to make sure modifications in the code didn't cause any new issues.
Server configuration can also be one of the bottlenecks that slow down Magento Add to Cart. With the help of a full-page cache, most server configuration flaws aren’t noticeable on most pages, therefore the performance drop isn’t so visible. At the same time, adding products to the cart is a resource-intensive process and server configuration issues can have a significant impact on the speed.
Make sure that the server on which the Magento installation is run is configured for optimal performance. One of the main performance metrics is the server response time. The lower the rate, the better the server is configured. More information on performance analysis and configuration can be found in our article on how to speed up Magento 2.
Over the past few years, merchants have started to focus on speeding up their landing and product pages, but the majority are still overlooking their checkout page.
These 5 tips mentioned in the article will help you to boost Magento Add to Cart's performance. After performance optimization, your Magento store will be able to provide a greatly improved checkout experience and help you to reduce the abandoned cart rate. Thus, your retail business will have a significant increase in terms of profit.
If you have another way to tune up Magento Add to Cart that we missed, feel free to mention it below in the comments section.