How to set default shipping address of the customer Magento 2?

Set Default shipping address id of the customer in Magento 2 using Address Repository Interface. You required Customer Id to set shipping address and address id you want to assign it. $address->setIsDefaultShipping(true) set the current address id to default address for the given customer.

Create my account link dynamically

Here we will learn how to create an account link on my account menu section with a condition. For that, we have to assign the custom block for the navigation code for customer_account.xml code for the custom block –> Vendor/module/Block/Customer/link.php We check a custom condition and print the resultant.

How to Extend Layout in Magento 2

Layout customization includes multiple tasks that help you change any elements in your pages. To customize your layout, create extending and overriding layout files in your custom theme. Just add the next layout file in the layout folder like <folder> —Layout –layout1.xml > layout2.xml For each layout file that is included in the list:Layout handle… Continue reading How to Extend Layout in Magento 2

Get Region Code by Region name in Magento 2

Magento 2 You can get Region Code by Region name using Directory Module. You can get region code from region name by Magento\Directory\Model\ResourceModel\Region\CollectionFactory object. Let’s check with Region name is California and we want to get region code CA from California. Call $this->getRegionCode(“California”); The result will be, by this we can also get the region id from the… Continue reading Get Region Code by Region name in Magento 2

Check whitespaces and remove in the First Name Customer Registration in FE, BE

Once a new customer is being registered and Add New Customer in Admin the extension checks the First Name field. If the First Name field has whitespaces, they must be removed, so the customer entity is saved without whitespaces in the First Name property. All checks and modifications must be performed on the server side.… Continue reading Check whitespaces and remove in the First Name Customer Registration in FE, BE

Product Collection Methods: addFieldToSelect() vs. addAttributeSelect()

What is the difference between ->addFieldToSelect(‘name’) and ->addAttributeToSelect(‘name’)? addAttributeToSelect() is used to select EAV collections. (like https://devdocs.magento.com/guides/v2.3/extension-dev-guide/attributes.html#customer-eav-attribute) addFieldToSelect() is used to select Non-EAV collections.

How to add a pop-up window to Magento 2 front page?

use pop-up solution I could use to put up a message to visitors Inside your theme add below file in path  app\design\frontend\your\theme\Magento_Cms\layout\cms_index_index.xml And Inside your theme add below file in path app\design\frontend\your\theme\Magento_Cms\templates\popup.phtml

Magento 2 create order programmatically

Here we are discussing how to create order programmatically in magetno Code for creating a quote Continuing to declare the order in the module helper file by the following function: