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 ...
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 ...
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 ...
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/...
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.
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 = $...
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
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 $...
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 ($...
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 = [
'...
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 ...
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/...
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\...
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 ...
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\...
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 $...
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/...
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:...
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 ...
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 ...
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:...
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\...
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:
...
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
&...
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->...
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
...
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)
{
$...
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/...
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 : ...
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')...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
shipping-address × 490magento2 × 231
checkout × 149
billing-address × 111
magento-1.9 × 63
shipping × 60
onepage-checkout × 59
shipping-methods × 53
customer-address × 42
magento-2.1 × 28
magento2.3 × 26
quote × 21
orders × 20
checkout-page × 17
address × 17
customer × 15
knockoutjs × 14
cart × 11
magento-1.7 × 10
event-observer × 10
customer-account × 9
magento2.2 × 8
magento2.4 × 8
onestepcheckout × 8
admin × 7