Removing New Address Options from Magento Onepage Checkout
As an experienced developer at Laravel Company, I often receive requests for customizing the checkout process to meet specific business requirements. In this post, we’ll guide you through removing the “Add New Address” option and the “Change Address” anchor from the sidebar in your Magento onepage checkout.
Understanding the Checkout Flow
Before diving into code changes, let’s understand the default checkout flow:
- Billing Step: This is where customers enter their shipping address. By default, they can either select an existing address or add a new one.
- Shipping Step: Similar to billing, customers can choose between available addresses or create a new one.
Removing “Add New Address” Option
To remove the “Add New Address” option from both the Billing and Shipping steps, you’ll need to override the core templates responsible for rendering these options. Here’s how:
-
Navigate to
app/design/frontend/[Your_Theme]/Magento_Checkout/templates/address/billing.phtmlandShipping.phtml. -
Locate the following line (around line 30):
<div class="actions-toolbar">
<div class="primary">
<button data-action="add" type="button" class="action primary checkout">
<?php /* @escapeNotVerified */ echo __('Add New Address') ?>
</button>
</div>
</div>
- Comment out or delete this entire
actions-toolbardiv to remove the “Add New Address” button.
Removing “Change Address” Anchor from Sidebar
Next, let’s remove the “Change Address” anchor from the sidebar that appears during the checkout process.
-
Navigate to your theme directory (
app/design/frontend/[Your_Theme]/Magento_Checkout) and locateweb/js/view/summary.billing-address.js. -
Open this file and look for the following line (around line 37):
changeAddress: function (addressId) {
var self = this;
require(['jquery'], function ($) {
$.mage.redirect('/', 'address_id=' + addressId);
});
},
- Comment out or delete this entire
changeAddressfunction to remove the “Change Address” functionality.
Verifying the Changes
After making these changes, clear your Magento cache using the command line:
php bin/magento cache:clean
Then, when you navigate back to the checkout page, you’ll find that the “Add New Address” option has been removed from both the Billing and Shipping steps. Additionally, the “Change Address” anchor will no longer appear in the sidebar.
At Laravel Company, we specialize in Magento customizations like these, helping businesses streamline their checkout process to meet unique requirements. If you need assistance with more complex modifications or have any other questions, feel free to contact our team of experienced developers.
Conclusion
By following this guide, you’ve successfully removed the “Add New Address” option and the “Change Address” anchor from your Magento onepage checkout. This will help ensure that customers can only change their addresses via the approved methods in your business process.
Remember, if you’re looking for professional development services or advanced customizations, Laravel Company is here to support you every step of the way. Don’t hesitate to reach out and explore how we can help optimize your e-commerce platform.