How to edit quantity display on Magento checkout page

How to edit quantity display on Magento checkout page

October 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to edit quantity display on Magento checkout page

Editing Quantity Display on Magento Checkout Page

If you’re facing issues with the quantity display on your Magento checkout page not reflecting user-defined values from bundle products, this guide will help you resolve it. We’ll be working with version 1.6.2.0 of the platform.

Understanding the Issue

The extension found here adds a quantity box to checkbox options on bundle products, but it fails to display the user-defined quantity accurately in the cart. The current setup always shows “1 X product” regardless of what customers enter.

Locating the Relevant Code

To adjust this behavior, we need to find and modify the code responsible for populating the cart with the correct quantities. In Magento 1.x, this involves editing core files which is generally not recommended due to upgrade complexities. However, in your case, since you’re on a stable release, let’s proceed carefully.

The primary function that handles this logic is located in app/code/core/Mage/Bundle/Model/Observer.php. Open this file for editing (make sure you have a backup before proceeding).

Editing the Observer File

Search for the following line within the afterAddToCart method:

$product->setCustomPrice($bundleItem['qty'] * $item['price']);

This line calculates the custom price based on the quantity and price of each bundle item. To ensure it correctly reflects user input, we need to update this calculation.

Replace the above line with the following:

$product->setCustomPrice($item['qty'] * $bundleItem['price']);

Here, we’re changing $bundleItem['qty'] to $item['qty']. This ensures that the quantity is taken from the user’s input in the cart, not from the pre-defined bundle item.

Updating the Cart Summary

While this change updates the individual items correctly, you might still see inconsistencies when viewing the cart summary. To fix this, open app/design/frontend/[your_package]/[your_theme]/template/checkout/cart/item/default.phtml.

Find the line that displays the product name and quantity in the cart summary:

<?php echo $this->getProductName($_item) ?>

Before this line, add the following code to display the user-defined quantity correctly:

<?php if ($_item->getCustomPrice() !== null): ?>
  <div class="cart-item-quantity">
    <?php echo $_item->getQty() ?> x <?php echo $this->getProductName($_item) ?>
  </div>
<?php endif; ?>

This code checks if a custom price is set (which happens when the user changes the quantity). If so, it displays the quantity followed by the product name.

Testing Your Changes

After saving your files, clear your cache to ensure Magento re-compiles its templates:

rm -rf var/cache/*
rm -rf var/session/*

Then refresh your checkout page. The quantity field should now display accurately based on user input throughout the cart summary and item breakdown.

Conclusion

Editing core files in Magento is a delicate process, but with careful targeting of the relevant functions, you can achieve desired changes without disrupting other system functionalities. In this case, updating the Observer file and adding custom logic to the cart template resolved the issue effectively for our specific extension within the provided context.

Remember, these are direct edits to core files which can cause conflicts during upgrades or when using other extensions that modify the same code base. Always keep backups of your original files and test thoroughly before deploying changes in a production environment.

For more extensive customizations and to avoid touching core files, consider leveraging Magento’s event-observer system or extension overrides provided by features like app/etc/modules configuration. These methods offer better long-term maintainability while still allowing you to customize the platform according to your specific requirements.

Happy coding!

Magento 1 Checkout Catalog Database

Our network