13 votes
Accepted

Magento 2 - Add CMS Static Block to Checkout Address Form

You'll have to do this with a module, it can't be done from within the theme. The idea is to get the CMS block's html and put it into the checkoutConfig JS object. We do this by adding a config ...
user avatar
  • 8,819
13 votes
Accepted

Programatically load default billing and shipping address

This is an example of getting default customer's billing and shipping address if you have the customerId and using the customerRepository Magento\Customer\Api\CustomerRepositoryInterface and the ...
user avatar
  • 2,156
12 votes
Accepted

How to get customer address by customer ID?

You cannot retrieve an address based on the customer id so this code will never work: $address = $this->_addressRepository->getByCustomerId($customerId);//error Because the getByCustomerId ...
user avatar
12 votes
Accepted

how to reorder (switch) billing address before shipping address

As Aaron pointed out the form is added in Magento/Checkout/Block/Checkout/LayoutProcessor.php. With this information I developed a module with an after plugin that hooks onto that processor: app/code/...
user avatar
  • 1,592
10 votes
Accepted

How to get formated order addresses

$billing = $order->getBillingAddress()->getFormated(); $shipping = $order->getShippingAddress()->getFormated(); getFormated supports an optional parameter that can be html or text.
user avatar
  • 196k
10 votes

Magento 2 - Add CMS Static Block to Checkout Address Form

This is what I did to display a CMS block on checkout page under sidebar. 1. In the templates/onepage.phtml I created a js variable to hold the cms block content like this: <?php $myCmsBlock = $...
user avatar
9 votes

How do I add a customer's email to the sales invoice?

You can get the customer email like this in the invoice or order templates: {{var order.getCustomerEmail()}} SO you can try to add Email: {{var order.getCustomerEmail()}} after {{var order....
user avatar
  • 196k
9 votes
Accepted

Street address #1 & #2

The street field contains street1 and street2 separated by a line break. In order to get one or the other just explode the string by \n. $street = explode('\n', $street); You can then just pull $...
user avatar
9 votes
Accepted

How to control Multiple Address Checkout on Magento admin settings?

You can disable the "Checkout with Multiple Addresses" option on your Magento website. Here's how: 1. Login to your Magento site's Admin Panel 2. Go to System and select Configuration 3. Go to ...
user avatar
  • 1,397
9 votes
Accepted

Get tax RATE for an order or invoice

Tax rate is not based on order, but on order item, so you will need to check these: $orderItem->getTaxPercent(). For invoice items you need to request the associated order item by calling $...
user avatar
  • 139
9 votes
Accepted

Limit country drop down input field Magento 2

Please allow only that need from Admin > Stores > Configuration > General > Country Options > Allow Countries
user avatar
8 votes
Accepted

How to remove telephone number as required field in billing and shipping on admin side?

Here's the SQL query for setting the attribute telephone to not required. UPDATE eav_attribute SET is_required = 0 WHERE attribute_code = 'telephone'; You might want this implemented in a setup ...
user avatar
8 votes

How to remove Guam, Palau, and other US Territories from address State dropdown - Magento 2

You can filter out the options using a Plugin for the toOptionArray() method of Magento\Directory\Model\ResourceModel\Region\Collection: class StateFilter { protected $disallowed = [ '...
user avatar
  • 8,819
8 votes
Accepted

How to get order shipping address data

The problem is that $order is not set or it's no object (of type Mage_Sales_Model_Order). Also order with downloadable products have no shipping address. Edit: For the updated questions ... make ...
user avatar
  • 11.5k
8 votes
Accepted

How to display company name on checkout page in Magento 2.1?

To add company name or any other address field in For add new field in shipping adress section, override vendor/magento/module-checkout/view/frontend/web/template/shipping-address/address-renderer/...
user avatar
  • 21.7k
8 votes
Accepted

How to get customer address with address id

You can get the formatted address using address id with below code: public function __construct( \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Customer\Model\...
user avatar
7 votes
Accepted

How to Check If given address is Default Shipping or Billing address using Address id Magento

$addressId = your id here; $address = Mage::getModel('customer/address')->load($addressId); $customer = $address->getCustomer(); $defaultBilling = $customer->getDefaultBillingAddress(); if ($...
user avatar
  • 196k
7 votes

How to get customer address by customer ID?

For get customer adderess using order id in .phtml file $customerId = 3; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerObj = $objectManager->create('Magento\...
user avatar
7 votes
Accepted

Magento 2.X - "Invalid Customer Address Id" comes randomly for the customers on checkout

I've checked it further and fixed this issue by overriding Magento's validateForCart function. /** * Validate address to be used for cart. * * @param CartInterface $cart * @param AddressInterface $...
user avatar
  • 4,705
6 votes
Accepted

Estimate Shipping Country Only?

The simplest option is probably to copy app/design/frontend/base/checkout/cart/shipping.phtml to your own theme and simply comment them out the 2 fields.
user avatar
6 votes
Accepted

How to remove zip postal code and country from checkout form?

Go to Configuration -> General -> Country Options Select only a single country (your default country) Select all country for the field Postal Code is Optional for the following countries. Update ...
user avatar
6 votes
Accepted

PayPal Express FIRSTNAME and LASTNAME instead of SHIPTONAME

In Model/Express/Checkout.php the returnFromPaypal($token) function includes this: $shippingAddress->setLastname(null); If I remove this, I can change the _exportAddressses function in Model/Api/...
user avatar
  • 712
6 votes

Magento 2 - How to change the SortOrder of the street address fields on the Shipping Checkout page

I don't know exactly why this works, but it's just working for me. If I set a sortOrder greater than 100, then these fields will be displayed after the street field: <item name="country_id" xsi:...
user avatar
  • 1,839
6 votes

Shipping Address Missing on Payment Page Refresh

Core file path: vendor/magento/module-checkout/view/frontend/web/js/checkout-data.js Overwrite To: app/design/frontend/VendorName/ThemeName/Magento_Checkout/web/js/checkout-data.js Copy below code ...
user avatar
  • 1,006
6 votes
Accepted

How to show a custom attribute in the admin Shipping Address box?

Navigate to System Configuration Stores -> Configuration -> Customers -> Customer Configuration -> Address Templates From Address Templates, Find HTML section, untick checkbox system ...
user avatar
6 votes
Accepted

While trying to delete address its redirecting to 404 page in Magento 2

I got the solution. Change 'HttpPostActionInterface' with 'HttpGetActionInterface'. vendor/magento/module-customer/Controller/Address/delete.php use Magento\Framework\App\Action\...
user avatar
  • 360
6 votes

Magneto 2: Different countries in billing and shipping address

For show only one country in shipping address country dropdown we have to create plugin of LayoutProcessor method for override country_id children field of shipping-address-fieldset which we found in ...
user avatar
  • 781
5 votes
Accepted

Change shipping and billing address from order programmatically

if you want update shipping address of an order then you need load order then load it address object: Step1:Order load by orded id $order = Mage::getModel('sales/order')->load($orderId); Step2:...
user avatar
  • 75.9k
5 votes

Magento2 : Change shipping address layout on checkout page

You could overwrite the template layout. This'll give you the most flexibility but may or may not have undesired consequences. In the shipping-address/form.html knockout template there is this code: ...
user avatar
  • 159
5 votes
Accepted

Magento 2 - Save custom shipping address' fields to quote_address table

For address save, you need to assign value into address object. Here is an example: Here delivery_date is a new custom column of quote_address table $billingAddress = $addressInformation->...
user avatar
  • 34.4k

Only top scored, non community-wiki answers of a minimum length are eligible