The Stack Overflow podcast is back! Listen to an interview with our new CEO.
15

You could use the order_address object to get the shipping address: $address = Mage::getModel('sales/order_address')->load($shippingId); // $shippingId is the id you get from order object. $custName = $address->getName(); $custAddr = $address->getStreetFull(); $region = $address->getRegion(); $country = $address->getCountry(); or use ...


12

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 addressRepository Magento\Customer\Api\AddressRepositoryInterface $customer = $this->customerRepository->getById($customerId); $billingAddressId = $customer-...


10

Use array_diff. $order = $invoice->getOrder(); $billing = $order->getBillingAddress()->getData(); $shipping = $order->getShippingAddress()->getData(); $diff = array_diff($billing,$shipping); ref: http://us3.php.net/array_diff you may have to strip out some of the data of each array, before the diff. I am sure you can work it out ;)


10

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/<vendor>/<module>/Model/Checkout/LayoutProcessorPlugin.php <?php namespace <vendor>\ReorderBillingForm\Model\Checkout; class ...


10

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 provider to Magento\Checkout\Model\CompositeConfigProvider Here is {module_dir}/etc/frontend/di.xml file: <?xml version="1.0"?> <config xmlns:xsi="http://...


9

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.shipping_address.format('html')}} [Edit] For pdf you should replace this from Mage_Sales_Model_Order_Pdf_Abstract::insertOrder $shippingAddress = $this->...


9

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 Shipping Settings on the left menu under Sales section 4. Set "Allow Shipping to multiple addresses" to "No" 5. Save Config If you do not see any changes make sure ...


9

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 $invoiceItem->getOrderItem()->getTaxPercent(). To get the whole tax information of an order, you may use $order->getFullTaxInfo();, which returns the whole ...


9

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 method does not exist in the service contract classes. What you can do though, is use the data service contract customer class with the following code: $...


8

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 $street[0] for street1 or $street[1] for street2. Alternatively if you are accessing the customer address object you can just call street1 or street2 directly to ...


8

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 script if you wish to package it in an extension. This does not override any frontend code, which may still require the telephone.


7

To get the Address from an order object you could simple do $order->getShippingAddress() Assuming $order_id = 123; // put your order id here $order = Mage::getModel('sales/order')->load($order_id); Then $address = $order->getShippingAddress(); $custName = $address->getName(); $custAddr = $address->getStreetFull(); $region = $address->...


7

Even though there is already an accepted answer, I'd like to share this solution I saw (similar) once in a 3rd party module: function serializeAddress(Mage_Sales_Model_Quote_Address $address) { return serialize( array( 'firstname' => $address->getFirstname(), 'lastname' => $address->...


7

You can filter out the options using a Plugin for the toOptionArray() method of Magento\Directory\Model\ResourceModel\Region\Collection: class StateFilter { protected $disallowed = [ 'Guam', 'Puerto Rico', 'Palau', 'Virgin Islands', 'Northern Mariana Islands', 'Marshall Islands', 'Federated States ...


7

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 = $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('my_cms_block')->toHtml() ?> <script type="text/javascript"> ...


7

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 sure loaded $order is valid. It seems the order you're are trying to load isn't correct.^ Use entity_id $order = Mage::getModel('sales/order')->load(19); ...


7

Please allow only that need from Admin > Stores > Configuration > General > Country Options > Allow Countries


6

You can just go to System->Configuration->Tax->Calculation Settings and set the field Tax Calculation Based On to Shipping Address. This way if the user tries to trick you and fills in the default address a country without taxes, he will see the catalog prices without taxes, but when he tries to checkout and fills in a different shipping address the ...


6

Magento supports multiple formats for addresses. IN this case the oneline format is used. You can view and edit this format in System->Configuration->Customer Configuration->Address Templates->Text One Line. The default value is. {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{...


6

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.


6

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 eav_attribute table and set is_required = 0 if attribute_code = 'postcode' You can remove the Zip/Postal Code fields on templates. Replace Country fields with this: ...


6

$billing = $order->getBillingAddress()->getFormated(); $shipping = $order->getShippingAddress()->getFormated(); getFormated supports an optional parameter that can be html or text.


6

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/Nvp.php to include 'firstname' => $data['FIRSTNAME'], 'lastname' => $data['LASTNAME'], instead of 'firstname' => $data['SHIPTONAME'], This will ...


6

$addressId = your id here; $address = Mage::getModel('customer/address')->load($addressId); $customer = $address->getCustomer(); $defaultBilling = $customer->getDefaultBillingAddress(); if ($defaultBilling) { if ($defaultBilling->getId() == $addressId) { //is default billing } else { //is not default billing } } else { ...


5

Okay, so here's my attempt following ProxiBlue's suggestion: $excludeKeys = array('entity_id', 'customer_address_id', 'quote_address_id', 'region_id', 'customer_id', 'address_type'); $oBillingAddress = $order->getBillingAddress()->getData(); $oShippingAddress = $order->getShippingAddress()->getData(); $oBillingAddressFiltered = array_diff_key($...


5

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:Get shipping address Id. $order->getShippingAddress()->getId(); Step3:Then reset shipping address object: $shippingAddress = Mage::getModel('sales/...


5

For get customer adderess using order id in .phtml file $customerId = 3; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerObj = $objectManager->create('Magento\Customer\Model\Customer')->load($customerId); $customerAddress = array(); foreach ($customerObj->getAddresses() as $address) { $customerAddress[] = $...


5

Here's a simple method that can be used to make any required address field optional. First create a plugin for Magento\Checkout\Block\Checkout\LayoutProcessor. Define the class as follow: <?php namespace Vendor\Module\Plugin; class LayoutProcessor { public function afterProcess( \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, ...


5

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/default.html For add new field in sidebar ship to section, override vendor/magento/module-checkout/view/frontend/web/template/shipping-information/address-...


5

You can get the formatted address using address id with below code: public function __construct( \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Customer\Model\Address\Config $addressConfig, \Magento\Customer\Model\Address\Mapper $addressMapper, ) { $this->addressRepository = $addressRepository; $this->...


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