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 ...
Aaron Allen's user avatar
  • 8,969
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 ...
Nikolas's user avatar
  • 2,281
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 ...
Raphael at Digital Pianism's 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/...
steros's user avatar
  • 1,622
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.
Marius's user avatar
  • 198k
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 = $...
Siju Joseph's user avatar
10 votes
Accepted

Limit country drop down input field Magento 2

Please allow only that need from Admin > Stores > Configuration > General > Country Options > Allow Countries
Bhavin iFlair's user avatar
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 $...
quafzi's user avatar
  • 139
8 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 ($...
Marius's user avatar
  • 198k
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 = [ '...
Aaron Allen's user avatar
  • 8,969
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 ...
sv3n's user avatar
  • 11.6k
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/...
Prince Patel's user avatar
  • 22.6k
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\...
Pankaj Pareek's user avatar
8 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 ...
Raj's user avatar
  • 821
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\...
Abhinav Singh's 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 $...
Sumit's user avatar
  • 4,825
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/...
loeffel's user avatar
  • 722
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:...
Andrea's user avatar
  • 1,849
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 ...
ManiMaran A's user avatar
  • 1,126
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 ...
Japs M2 Developer's user avatar
6 votes
Accepted

Magento 2 : how can i add notice below state/province field in shipping address in checkout page

1.Create a di.xml under 'etc' directory of your any custom module <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:...
Magento Dev's user avatar
  • 1,254
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\...
soofz's user avatar
  • 360
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: ...
brenjt's user avatar
  • 159
5 votes

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

If you want to remove the states during checkout and also while adding or editing address from my account then you need the following solution Step 1 app/code/NAMESPACE/CustomDirectory/etc/di.xml &...
Abbas's user avatar
  • 493
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->...
Sohel Rana's user avatar
  • 35.6k
5 votes

Magento 2 : Default billing address not selected by default on checkout page

You could do the following: overwrite a default js file checkout-data-resolver.js add extra lines to the applyBillingAddress function to check if default billing address exists and if true to use it ...
Михаил Крылов's user avatar
5 votes

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

You can change the street input sort order using a plugin for Magento\Checkout\Block\Checkout\LayoutProcessor: class Reorder { public function afterProcess($subject, $jsLayout) { $...
Aaron Allen's user avatar
  • 8,969
5 votes

Magento 2 : Event Observer For Shipping Address Selection

You should use plugin to get the shipping info: Your di should be under etc folder: app/code/Extension/Vendor/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/...
Khoa TruongDinh's user avatar
5 votes
Accepted

Magento 2.1.2, Remove "region" from the Address

If you want disable Region from the address, you have to set below option like. State is Required for : remove all selected country from here. Allow to Choose State if It is Optional for Country : ...
Suresh Chikani's user avatar
5 votes

How to get the value of custom field checkout address in Carrier Model Magento 2

finally found the solution, using php function to get the raw json input, here's the code: public function collectRates(RateRequest $request) { $data = json_decode(file_get_contents('php://input')...
simple guy's user avatar
  • 2,474

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