Categories
CMS Magento Mastering Development

Checkout custom shipping address field – set as required

I have created a custom module that adds a text field in shipping address. It’s workin ok but I’d like to make it required. How can I do that? I tried adding ‘required-entry’ => true at validation parameter, in file Plugin/Checkout/LayoutProcessor.php but it didn’t work. Here are the module files: Mymodules/FieldCheckout/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, ‘Mymodules_FieldCheckout’, […]

Categories
CMS Development Magento

Can get shipping extension_attributes in observer Magento 2

Hi I want to save a shipping address attribute by observer sales_model_service_quote_submit_before Bellow My observer: public function execute(Observer $observer) { $quote = $observer->getEvent()->getQuote(); $fields = $this->fieldsManagement->getByQuoteId($quote->getId()); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $resource = $objectManager->get(‘Magento\Framework\App\ResourceConnection’); $customer_res = $objectManager->create(‘Magento\Customer\Api\AddressRepositoryInterface’); $customer = $customer_res->getById(101); $shippingAddress = $quote->getShippingAddress(); $shippingAddressExtensionAttributes = $shippingAddress->getExtensionAttributes(); if ($shippingAddressExtensionAttributes) { $customField = $shippingAddressExtensionAttributes->getDistance(); $customer->setCustomAttribute(‘distance’,$customField); }else{ $customer->setCustomAttribute(‘distance’,’not save’); } […]

Categories
CMS Development Magento

Magento 2 hide shipping methods based on product attribute & shipping address out of USA

I Would like to hide shipping methods and display a custom message on the checkout page & cart page based on product attribute flag & if the shipping address is outside of the USA. I used the below plugin but it triggers only logged-in users unable to verify with guest users. Could you please advise […]

Categories
CMS Development Magento

Magento 2 hide shipping methods based on product attribute & shipping address

I Would like to hide shipping methods and display a custom message on the checkout page & cart page based on product attribute flag & if the shipping address is outside of the USA. I used the below plugin but it triggers only logged-in users unable to verify with guest users. Could you please advise […]

Categories
CMS Development Magento

Magento 2 hide shipping methods based on product attribute

I Would like to hide shipping methods and display custom message on the checkout page & cart page based on product attribute flag & if the shipping address is outside of the USA. I used the below plugin but it triggers only logged-in users unable to verify with guest users. Could you please advise what […]

Categories
CMS Development Magento

How to display a message when unset a shipping method in magento 2.3 using aroundEstimateByExtendedAddress plugin?

Want to display a message after certain conditions, how to achieve that? class ShipmentEstimationPlugin { public function __construct( \Magento\Customer\Model\Session $customerSession ) { $this->customerSession = $customerSession; } public function aroundEstimateByExtendedAddress( ShipmentEstimationInterface $subject, \Closure $proceed, $cartId, \Magento\Quote\Api\Data\AddressInterface $address ) { $writer = new \Zend\Log\Writer\Stream(BP . ‘/var/log/testshipping.log’); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get(‘\Magento\Checkout\Model\Cart’); […]

Categories
CMS Development Magento

aroundSavePaymentInformationAndPlaceOrder plugin not working in magento 2

etc/di.xml <?xml version=”1.0″ encoding=”UTF-8″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <!– this plugin not working –> <type name=”Magento\Checkout\Model\PaymentInformationManagement”> <plugin name=”save_order_comment_now” type=”Order\Custom\Plugin\PaymentInformationManagementPlugin”/> </type> <!– this plugin is working–> <type name=”Magento\Sales\Api\OrderManagementInterface”> <plugin name=”before_place_order_operation” type=”Order\Custom\Plugin\OrderManagement”/> </type> that not working plugin class <?php namespace Order\Custom\Plugin; class PaymentInformationManagementPlugin { protected $orderRepository; public function __construct( \Magento\Sales\Api\OrderRepositoryInterface $orderRepository ) { $this->orderRepository = $orderRepository; } public […]