Loading..
Processing... Please wait...

Product was successfully added to your shopping cart.



5 fixes for slow Magento 1.9 checkout & add to cart

Slow magento checkout can ruin your e-commerce business. Nobody likes to wait in line.

I will show you 5 ways to speed up magento checkout / add to cart that could also improve conversion rates.

1. Disable shipping methods you don't use

By default magento enables Fedex, USPS, UPS, DHL shipping methods. They all send requests to external gateways to collect shipping rates = performance hog.

To give you an idea of how much it slows down checkout let us add profiler marks to app/code/core/Mage/Shipping/Model/Shipping.php collectRates call:

public function collectRates(
Mage_Shipping_Model_Rate_Request $request
)
{                                   
 ......                                        
 foreach ($carriers as $carrierCode => $carrierConfig) {
   Varien_Profiler::start($carrierCode);
   $this->collectCarrierRates($carrierCode, $request);
   Varien_Profiler::stop($carrierCode);                                                                                                                              
 }
......

Then we go through cart and checkout pages and see profiler trace:

cart page:

Cart page profiler | Magento checkout / add to cart slow Cart page profiler | Magento checkout / add to cart slow

saveBilling action:

saveBilling action | Magento checkout / add to cart slow saveBilling action | Magento checkout / add to cart slow

savePayment:

savePayment action | Magento checkout / add to cart slow savePayment action | Magento checkout / add to cart slow

Here are exact times for rates collecting:

  • Fedex - 600ms
  • UPS - 424ms
  • USPS - 406ms
  • DHL - 518ms

In total magento spends around 2 seconds(!) collecting shipping rates.

If for example you are only using UPS then by disabling Fedex, USPS, DHL at System > Configuration > Shipping Methods you can speed up magento add to cart action (if it redirects to cart page) and magento checkout by minimum 1.5 seconds.

 

2. Remove estimate shipping block from cart page

Estimate shipping and tax block on cart page can contribute to high cart page load time.

Estimate shipping and tax costs | Magento checkout / add to cart slow Estimate shipping and tax costs | Magento checkout / add to cart slow

To remove this block add the following lines to your theme local.xml file:

 <checkout_cart_index>
    <remove name="checkout.cart.shipping"/>    
 </checkout_cart_index>

 

3. Optimize rates collecting

Suppose you do need Fedex, USPS, UPS, DHL shipping methods. How do you keep them enabled and speed up slow magento checkout?

When you choose a payment method during checkout magento recollects shipping rates. It might be useful if your shipping costs depend on payment method but in other cases it slows down checkout.

Overwrite app/code/core/Mage/Checkout/Model/Type/Onepage.php savePayment function around line 659:

+ $quote->getShippingAddress()->setCollectShippingRates(false);                                                                                                             
  $payment->importData($data);

Disclaimer: in app/code/core/Mage/Checkout/Model/Type/Onepage.php savePayment function I see a comment "shipping totals may be affected by payment method". It means it recollects shipping rates for a reason but I have no idea how shipping totals may be affected by payment method. In most scenarios it does not.

 

 

4. Disable gift message extension

Gift message extension adds its 140ms to save billing checkout step.

Gift message checkout 140ms | Magento add to cart / checkout slow Gift message checkout 140ms | Magento add to cart / checkout slow

If you don't use gift messages for your products disable Mage_GiftMessage extention at System > Configuration > Advanced:

Disable Mage_GiftMessage extension | Magento add to cart / checkout slow Disable Mage_GiftMessage extension | Magento add to cart / checkout slow

5. Disable configurable swatches observer for checkout

Makes sense if you have configurable products in catalog. Saves around 50ms for every item in cart. 10 cart items = 0.5s !

Configurable swatches checkout event | Magento add to cart / checkout slow Configurable swatches checkout event | Magento add to cart / checkout slow

Magento dispatches catalog_product_attribut_backend_media_load_gallery_before event on every product model load. Configurable swatches default magento extension listens to that event and fires loadChildProductImagesOnMediaLoad function to preload images for various configurable product combinations. We might not need these images while placing order.

To disable this observer for checkout only overwrite app/code/core/Mage/ConfigurableSwatches/Model/Observer.php loadChildProductImagesOnMediaLoad function:

public function loadChildProductImagesOnMediaLoad(Varien_Event_Observer $observer) {

+        if(Mage::app()->getRequest()->getRouteName() == 'checkout') return;                                                                                                       
          if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled
            return; // exit without loading swatch functionality

 

Want to know how to speed up magento even more? Check out these 20 proven steps to increase magento performance.

 

 

If you find this post interesting do not hesitate to sign up for our newsletter and join the 636 people who receive Magento news, tips and tricks regularly.

Thank You!

 

 

2 thoughts on “5 fixes for slow Magento 1.9 checkout & add to cart”